Changeset View
Changeset View
Standalone View
Standalone View
src/aphront/response/AphrontUnhandledExceptionResponse.php
| <?php | <?php | ||||
| final class AphrontUnhandledExceptionResponse | final class AphrontUnhandledExceptionResponse | ||||
| extends AphrontStandaloneHTMLResponse { | extends AphrontStandaloneHTMLResponse { | ||||
| private $exception; | private $exception; | ||||
| public function setException(Exception $exception) { | public function setException(Exception $exception) { | ||||
| // Log the exception unless it's specifically a silent malformed request | |||||
| // exception. | |||||
| $should_log = true; | |||||
| if ($exception instanceof AphrontMalformedRequestException) { | |||||
| if ($exception->getIsUnlogged()) { | |||||
| $should_log = false; | |||||
| } | |||||
| } | |||||
| if ($should_log) { | |||||
| phlog($exception); | |||||
| } | |||||
| $this->exception = $exception; | $this->exception = $exception; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function getHTTPResponseCode() { | public function getHTTPResponseCode() { | ||||
| return 500; | return 500; | ||||
| } | } | ||||
| protected function getResources() { | protected function getResources() { | ||||
| return array( | return array( | ||||
| 'css/application/config/config-template.css', | 'css/application/config/config-template.css', | ||||
| 'css/application/config/unhandled-exception.css', | 'css/application/config/unhandled-exception.css', | ||||
| ); | ); | ||||
| } | } | ||||
| protected function getResponseTitle() { | protected function getResponseTitle() { | ||||
| $ex = $this->exception; | $ex = $this->exception; | ||||
| if ($ex instanceof AphrontUsageException) { | if ($ex instanceof AphrontMalformedRequestException) { | ||||
| return $ex->getTitle(); | return $ex->getTitle(); | ||||
| } else { | } else { | ||||
| return pht('Unhandled Exception'); | return pht('Unhandled Exception'); | ||||
| } | } | ||||
| } | } | ||||
| protected function getResponseBodyClass() { | protected function getResponseBodyClass() { | ||||
| return 'unhandled-exception'; | return 'unhandled-exception'; | ||||
| } | } | ||||
| protected function getResponseBody() { | protected function getResponseBody() { | ||||
| $ex = $this->exception; | $ex = $this->exception; | ||||
| if ($ex instanceof AphrontUsageException) { | if ($ex instanceof AphrontMalformedRequestException) { | ||||
| $title = $ex->getTitle(); | $title = $ex->getTitle(); | ||||
| } else { | } else { | ||||
| $title = get_class($ex); | $title = get_class($ex); | ||||
| } | } | ||||
| $body = $ex->getMessage(); | $body = $ex->getMessage(); | ||||
| $body = phutil_escape_html_newlines($body); | $body = phutil_escape_html_newlines($body); | ||||
| Show All 31 Lines | |||||