private function init() { // Storage $this->storage = $storage = new Storage(); $storage->sync(); // Database $this->db = new \Medoo(); // Router $this->router = $router = new Router($this->url); // Plugins $this->pluginLoader = $pluginLoader = new PluginLoader(); $pluginLoader->load(); // For the logger $this->addHook('app_endlife', function () { global $app; $app->saveLog(); }); // Error handling $handler = new \Error\Handler(); $handler->error(function (\Twig_Error $e) { echo 'A templating error occurred <br />'; echo $e->getMessage(); })->error(function (\Twig_Error_Syntax $e) { echo 'A templating error occurred in syntax <br />'; echo $e->getMessage(); })->error(function (\Twig_Error_Runtime $e) { echo 'A templating error occurred at runtime <br />'; echo $e->getMessage(); })->error(function (\Twig_Error_Loader $e) { echo 'A templating error occurred in the loader <br />'; echo $e->getMessage(); })->error(function (\Twig_Sandbox_SecurityError $e) { echo 'A templating error occurred in a sandbox <br />'; echo $e->getMessage(); }); }
<?php /** * Simple error handler * * @see https://github.com/mrjgreen/error * @author Petr Pliska <*****@*****.**> */ $handler = new Error\Handler(); $handler->error(function (\Exception $e) { $response = getenv('DISPLAY_ERRORS') === 'true' ? App\exceptionToHtmlResponse($e) : App\renderExceptionTemplateToHtmlResponse($e); /* * Emittes PSR-7 message */ (new Zend\Diactoros\Response\SapiEmitter())->emit($response); });