-
-
Notifications
You must be signed in to change notification settings - Fork 186
/
Handler.php
57 lines (50 loc) · 1.56 KB
/
Handler.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
namespace App\Exceptions;
use Exception;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Symfony\Component\HttpKernel\Exception\HttpException;
class Handler extends ExceptionHandler
{
/**
* A list of the exception types that should not be reported.
*
* @var array
*/
protected $dontReport = [
\Symfony\Component\HttpKernel\Exception\HttpException::class,
];
/**
* Report or log an exception.
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $e
*
* @return void
*/
public function report(Exception $e)
{
if (app()->bound('sentry') && $this->shouldReport($e)) {
app('sentry')->captureException($e);
}
return parent::report($e);
}
/**
* Render an exception into a response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $exception
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function render($request, Exception $exception)
{
// Convert all non-http exceptions to a proper 500 http exception
// if we don't do this exceptions are shown as a default template
// instead of our own view in resources/views/errors/500.blade.php
if ($this->shouldReport($exception) && !$this->isHttpException($exception) && !config('app.debug')) {
$exception = new HttpException(500, 'Whoops!');
}
return parent::render($request, $exception);
}
}