/**
  * @param Container|Application $app
  */
 public function register(Container $app)
 {
     ini_set('log_errors', 1);
     strtoupper(env('APP_ENV')) === 'PRODUCTION' ? ini_set('display_errors', 0) : ini_set('display_errors', 1);
     $app['debug'] = env('DEBUG');
     !$app['debug'] ?: ($app['dump'] = $app->protect(function ($var) {
         return (new VarDumper())::dump($var);
     }));
     /** Register the app error factory */
     $app->error(function (\Exception $e) use($app) {
         // handle HTTP exceptions
         if (get_class($e) === NotFoundHttpException::class) {
             /** @var NotFoundHttpException $e */
             /** @noinspection DegradedSwitchInspection */
             switch ($e->getStatusCode()) {
                 case 404:
                     return response(view('404.html', ['error' => '404 - Page Not Found.']), 404);
                     break;
                 default:
                     $message = 'We are sorry, but something went terribly wrong.';
             }
             return new Response($message);
         }
         // not an HTTP exception
         throw $e;
     });
     if ($app['debug']) {
         error_reporting(E_ALL);
         ini_set('display_errors', 1);
         # core debug utilities
         # note that debug requires that the environment has been loaded
         include_once BOOT . 'assets/debug.php';
     }
 }
Beispiel #2
0
 public function register(Container $app)
 {
     if ($app instanceof Application) {
         $app->error(function (\Exception $e, Request $request, $code) use($app) {
             return $app->offsetGet("error.controller")->index($e, $request, $code);
         });
     }
 }
 public function register(Container $app)
 {
     $app['bugsnag'] = function ($app) {
         $client = Client::make($app['bugsnag.options']['apiKey']);
         $client->setNotifier(['name' => 'Silex Bugsnag', 'version' => static::VERSION, 'url' => 'https://github.com/fortis/silex-bugsnag']);
         Handler::register($client);
         return $client;
     };
     $app->error(function (\Exception $error, Request $request) use($app) {
         $params['request'] = ['params' => $request->query->all(), 'requestFormat' => $request->getRequestFormat()];
         $app['bugsnag']->notifyException($error);
     });
 }