From 509dad0c75af1b9d306e5ba5eba9b1deebf15a22 Mon Sep 17 00:00:00 2001 From: David Cramer Date: Thu, 28 Jul 2016 09:29:57 -0400 Subject: [PATCH] Add Feedback to Laravel example --- examples/laravel-4.2/app/routes.php | 17 ++++- .../laravel-5.2/app/Exceptions/Handler.php | 5 +- examples/laravel-5.2/app/Http/routes.php | 16 ++++- .../resources/views/errors/500.blade.php | 65 +++++++++++++++++++ 4 files changed, 99 insertions(+), 4 deletions(-) create mode 100644 examples/laravel-5.2/resources/views/errors/500.blade.php diff --git a/examples/laravel-4.2/app/routes.php b/examples/laravel-4.2/app/routes.php index c161bb77..4c6942bc 100644 --- a/examples/laravel-4.2/app/routes.php +++ b/examples/laravel-4.2/app/routes.php @@ -11,8 +11,21 @@ | */ -Route::get('/', function() +function verifyCredentials() { + Log::info('Verifying credentials'); + throw new Exception('No credentials passed!'); +} + + +function authenticateUser() +{ + Log::info('Authenticating the current user'); + verifyCredentials(); +} + + +Route::get('/', function () { Log::info('Rendering a page thats about to error'); - throw new Exception('An unhandled exception'); + authenticateUser(); }); diff --git a/examples/laravel-5.2/app/Exceptions/Handler.php b/examples/laravel-5.2/app/Exceptions/Handler.php index bd7015d4..c65248c4 100644 --- a/examples/laravel-5.2/app/Exceptions/Handler.php +++ b/examples/laravel-5.2/app/Exceptions/Handler.php @@ -48,6 +48,9 @@ public function report(Exception $e) */ public function render($request, Exception $e) { - return parent::render($request, $e); + // return parent::render($request, $e); + return response()->view('errors.500', [ + 'sentryID' => app('sentry')->getLastEventID(), + ], 500); } } diff --git a/examples/laravel-5.2/app/Http/routes.php b/examples/laravel-5.2/app/Http/routes.php index af7ca31c..7c59fc89 100644 --- a/examples/laravel-5.2/app/Http/routes.php +++ b/examples/laravel-5.2/app/Http/routes.php @@ -11,7 +11,21 @@ | */ +function verifyCredentials() +{ + Log::info('Verifying credentials'); + throw new Exception('No credentials passed!'); +} + + +function authenticateUser() +{ + Log::info('Authenticating the current user'); + verifyCredentials(); +} + + Route::get('/', function () { Log::info('Rendering a page thats about to error'); - throw new Exception('An unhandled exception'); + authenticateUser(); }); diff --git a/examples/laravel-5.2/resources/views/errors/500.blade.php b/examples/laravel-5.2/resources/views/errors/500.blade.php new file mode 100644 index 00000000..9facef2d --- /dev/null +++ b/examples/laravel-5.2/resources/views/errors/500.blade.php @@ -0,0 +1,65 @@ + + + + Internal Server Error + + + + + + +
+
+
Something went wrong.
+ @unless(empty($sentryID)) + + + + + @endunless +
+
+ +