File tree 1 file changed +8
-0
lines changed 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change 2
2
3
3
namespace App \Exceptions ;
4
4
5
+ use Exception ;
6
+ use Illuminate \Database \Eloquent \ModelNotFoundException ;
5
7
use Symfony \Component \HttpKernel \Exception \HttpException ;
8
+ use Symfony \Component \HttpKernel \Exception \NotFoundHttpException ;
6
9
use Illuminate \Foundation \Exceptions \Handler as ExceptionHandler ;
7
10
8
11
class Handler extends ExceptionHandler
@@ -14,6 +17,7 @@ class Handler extends ExceptionHandler
14
17
*/
15
18
protected $ dontReport = [
16
19
HttpException::class,
20
+ ModelNotFoundException::class,
17
21
];
18
22
19
23
/**
@@ -38,6 +42,10 @@ public function report($e)
38
42
*/
39
43
public function render ($ request , $ e )
40
44
{
45
+ if ($ e instanceof ModelNotFoundException) {
46
+ $ e = new NotFoundHttpException ($ e ->getMessage (), $ e );
47
+ }
48
+
41
49
return parent ::render ($ request , $ e );
42
50
}
43
51
}
You can’t perform that action at this time.
0 commit comments