1
0
mirror of https://github.com/cydrobolt/polr.git synced 2024-11-12 21:22:28 +01:00

Fix error handling for API errors and misc status codes fix #176

This commit is contained in:
Chaoyi Zha 2016-05-13 18:44:09 -04:00
parent 3dc4285b77
commit 7981709c6e
2 changed files with 14 additions and 4 deletions

View File

@ -5,11 +5,10 @@ namespace App\Exceptions;
use Exception;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Laravel\Lumen\Exceptions\Handler as ExceptionHandler;
use Illuminate\Support\Facades\Response;
class Handler extends ExceptionHandler
{
class Handler extends ExceptionHandler {
/**
* A list of the exception types that should not be reported.
*
@ -47,7 +46,17 @@ class Handler extends ExceptionHandler
return view('errors.404');
}
if ($e instanceof HttpException){
return view('errors.500');
$status_code = $e->getStatusCode();
$status_message = $e->getMessage();
if ($status_code == 500) {
// Render a nice error page for 500s
return view('errors.500');
}
else {
// If not 500, then render generic page
return response(view('errors.generic', ['status_code' => $status_code, 'status_message' => $status_message]), $status_code);
}
}
}

View File

@ -0,0 +1 @@
{{ $status_code }} {{ $status_message }}