Path: blob/master/src/aphront/handler/PhabricatorDefaultRequestExceptionHandler.php
12241 views
<?php12final class PhabricatorDefaultRequestExceptionHandler3extends PhabricatorRequestExceptionHandler {45public function getRequestExceptionHandlerPriority() {6return 900000;7}89public function getRequestExceptionHandlerDescription() {10return pht('Handles all other exceptions.');11}1213public function canHandleRequestThrowable(14AphrontRequest $request,15$throwable) {1617if (!$this->isPhabricatorSite($request)) {18return false;19}2021return true;22}2324public function handleRequestThrowable(25AphrontRequest $request,26$throwable) {2728$viewer = $this->getViewer($request);2930// Some types of uninteresting request exceptions don't get logged, usually31// because they are caused by the background radiation of bot traffic on32// the internet. These include requests with bad CSRF tokens and33// questionable "Host" headers.34$should_log = true;35if ($throwable instanceof AphrontMalformedRequestException) {36$should_log = !$throwable->getIsUnlogged();37}3839if ($should_log) {40phlog($throwable);41}4243$class = get_class($throwable);44$message = $throwable->getMessage();4546if ($throwable instanceof AphrontSchemaQueryException) {47$message .= "\n\n".pht(48"NOTE: This usually indicates that the MySQL schema has not been ".49"properly upgraded. Run '%s' to ensure your schema is up to date.",50'bin/storage upgrade');51}5253if (PhabricatorEnv::getEnvConfig('phabricator.developer-mode')) {54$trace = id(new AphrontStackTraceView())55->setUser($viewer)56->setTrace($throwable->getTrace());57} else {58$trace = null;59}6061$content = phutil_tag(62'div',63array('class' => 'aphront-unhandled-exception'),64array(65phutil_tag('div', array('class' => 'exception-message'), $message),66$trace,67));6869$dialog = new AphrontDialogView();70$dialog71->setTitle(pht('Unhandled Exception ("%s")', $class))72->setClass('aphront-exception-dialog')73->setUser($viewer)74->appendChild($content);7576if ($request->isAjax()) {77$dialog->addCancelButton('/', pht('Close'));78}7980return id(new AphrontDialogResponse())81->setDialog($dialog)82->setHTTPResponseCode(500);83}8485}868788