public function onException(GetResponseForExceptionEvent $exceptionEvent) { $exception = $exceptionEvent->getException(); if (isset($this->app['json.exception.handler'])) { $response = $this->app['json.exception.handler']($exception, $this->app); } else { $response = ErrorHandler::jsonExceptionError($exception, $this->app['appName']); } $exceptionEvent->setResponse($response); }
protected function defaultHandler(Application $app) { $error = error_get_last(); if ($error['type'] == E_ERROR || $error['type'] == E_COMPILE_ERROR || $error['type'] == E_PARSE || $error['type'] == E_USER_ERROR || $error['type'] == E_RECOVERABLE_ERROR) { /* * SOAP Errors are handled as exceptions so we need to ignore the fact that soap also places errors on the * PHP ErrorLog stack internally. */ if (stristr($error['message'], 'SOAP-ERROR') !== false) { return; } if (isset($app['newrelic'])) { $app['newrelic']->noticeError(implode(":", $error)); } ErrorHandler::sendJsonFatalError($error, $app->getAppName()); exit; } else { /* * @todo add code to handle notices / warnings */ } }
public function onRequestStart(GetResponseEvent $responseEvent) { $request = $responseEvent->getRequest(); $jsonContent = $request->getContent(); if (empty($jsonContent)) { return; } $parser = new JsonParser(); $result = $parser->lint($jsonContent); if ($result instanceof ParsingException) { $appPrefix = null; if (is_callable(array($this->app, "getClientName"))) { $appPrefix = ucwords($this->app->getClientName()); } if (is_callable(array($this->app, "getAppName"))) { $appPrefix = ucwords($this->app->getAppName()); } /** * @todo make use configurable DI injected error handler provider */ $responseEvent->setResponse(ErrorHandler::jsonExceptionError($result, $appPrefix)); } }