Summary:
Ref T12855. PHP7 introduced "Throwables", which are sort of like super exceptions. Some errors that PHP raises at runtime have become Throwables instead of old-school errors now.
The major effect this has is blank pages during development under PHP7 for certain classes of errors: they skip all the nice "show a pretty error" handlers and
This isn't a compelete fix, but catches the most common classes of unexpected Throwable and sends them through the normal machinery. Principally, it shows a nice stack trace again instead of a blank page for a larger class of typos and minor mistakes.
Test Plan:
Before: blank page. After:
{F5007979}
Reviewers: chad, amckinley
Reviewed By: chad
Maniphest Tasks: T12855
Differential Revision: https://secure.phabricator.com/D18136
34 lines
806 B
PHP
34 lines
806 B
PHP
<?php
|
|
|
|
final class PhabricatorConduitRequestExceptionHandler
|
|
extends PhabricatorRequestExceptionHandler {
|
|
|
|
public function getRequestExceptionHandlerPriority() {
|
|
return 100000;
|
|
}
|
|
|
|
public function getRequestExceptionHandlerDescription() {
|
|
return pht('Responds to requests made by Conduit clients.');
|
|
}
|
|
|
|
public function canHandleRequestThrowable(
|
|
AphrontRequest $request,
|
|
$throwable) {
|
|
return $request->isConduit();
|
|
}
|
|
|
|
public function handleRequestThrowable(
|
|
AphrontRequest $request,
|
|
$throwable) {
|
|
|
|
$response = id(new ConduitAPIResponse())
|
|
->setErrorCode(get_class($throwable))
|
|
->setErrorInfo($throwable->getMessage());
|
|
|
|
return id(new AphrontJSONResponse())
|
|
->setAddJSONShield(false)
|
|
->setContent($response->toDictionary());
|
|
}
|
|
|
|
}
|