1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Exceptions; |
4
|
|
|
|
5
|
|
|
use Exception; |
6
|
|
|
use Illuminate\Validation\ValidationException; |
7
|
|
|
use Illuminate\Auth\Access\AuthorizationException; |
8
|
|
|
use Illuminate\Database\Eloquent\ModelNotFoundException; |
9
|
|
|
use Symfony\Component\HttpKernel\Exception\HttpException; |
10
|
|
|
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; |
11
|
|
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
12
|
|
|
|
13
|
|
|
class Handler extends ExceptionHandler |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* A list of the exception types that should not be reported. |
17
|
|
|
* |
18
|
|
|
* @var array |
19
|
|
|
*/ |
20
|
|
|
protected $dontReport = [ |
21
|
|
|
AuthorizationException::class, |
22
|
|
|
HttpException::class, |
23
|
|
|
ModelNotFoundException::class, |
24
|
|
|
ValidationException::class, |
25
|
|
|
]; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Report or log an exception. |
29
|
|
|
* |
30
|
|
|
* This is a great spot to send exceptions to Sentry, Bugsnag, etc. |
31
|
|
|
* |
32
|
|
|
* @param \Exception $e |
33
|
|
|
* @return void |
34
|
|
|
*/ |
35
|
|
|
public function report(Exception $e) |
36
|
|
|
{ |
37
|
|
|
parent::report($e); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Render an exception into an HTTP response. |
42
|
|
|
* |
43
|
|
|
* @param \Illuminate\Http\Request $request |
44
|
|
|
* @param \Exception $e |
45
|
|
|
* @return \Illuminate\Http\Response |
46
|
|
|
*/ |
47
|
|
|
public function render($request, Exception $e) |
48
|
|
|
{ |
49
|
|
|
if($e instanceof NotFoundHttpException) |
50
|
|
|
{ |
51
|
|
|
// return response()->view('404', [], 404); |
|
|
|
|
52
|
|
|
return response()->view('404', compact('e'), 404); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
return parent::render($request, $e); |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.