/** * Handle an uncaught exception * * @param \Throwable $e * @return void */ public function handleException($e) { $this->emitter->run('application.error', $e); $app = Bootstrap::get('app'); $exceptionView = new ExceptionView(); $exceptionView->exceptionHandler($app, $e); }
use Directus\View\JsonView; use Directus\View\ExceptionView; use Directus\Db\TableGateway\DirectusIPWhitelist; use Zend\Db\Sql\Expression; // API Version shortcut for routes: $v = API_VERSION; /** * Slim App & Directus Providers */ $app = Bootstrap::get('app'); $requestNonceProvider = new RequestNonceProvider(); /** * Catch user-related exceptions & produce client responses. */ $app->config('debug', false); $exceptionView = new ExceptionView(); $exceptionHandler = function (\Exception $exception) use($app, $exceptionView) { $exceptionView->exceptionHandler($app, $exception); }; $app->error($exceptionHandler); // // Catch runtime erros etc. as well // set_exception_handler($exceptionHandler); // Routes which do not need protection by the authentication and the request // nonce enforcement. $authAndNonceRouteWhitelist = array("auth_login", "auth_logout", "auth_session", "auth_clear_session", "auth_nonces", "auth_permissions", "debug_acl_poc"); $app->hook('slim.before.dispatch', function () use($app, $requestNonceProvider, $authAndNonceRouteWhitelist) { /** Skip routes which don't require these protections */ $routeName = $app->router()->getCurrentRoute()->getName(); if (!in_array($routeName, $authAndNonceRouteWhitelist)) { /** Enforce required authentication. */ if (!Auth::loggedIn()) {