mirror of
https://github.com/cydrobolt/polr.git
synced 2024-11-13 21:52:29 +01:00
Fix error handling for API errors and misc status codes fix #176
This commit is contained in:
parent
3dc4285b77
commit
7981709c6e
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
1
resources/views/errors/generic.blade.php
Normal file
1
resources/views/errors/generic.blade.php
Normal file
@ -0,0 +1 @@
|
||||
{{ $status_code }} {{ $status_message }}
|
Loading…
Reference in New Issue
Block a user