This repository was archived by the owner on Jul 4, 2018. It is now read-only.
File tree 2 files changed +26
-0
lines changed
2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 8
8
use Illuminate \Database \Eloquent \ModelNotFoundException ;
9
9
use Laravel \Lumen \Exceptions \Handler as ExceptionHandler ;
10
10
use Symfony \Component \HttpKernel \Exception \HttpException ;
11
+ use Symfony \Component \HttpKernel \Exception \NotFoundHttpException ;
11
12
12
13
class Handler extends ExceptionHandler
13
14
{
@@ -45,6 +46,22 @@ public function report(Exception $e)
45
46
*/
46
47
public function render ($ request , Exception $ e )
47
48
{
49
+ if ($ this ->isNotFound ($ e )) {
50
+ return response (view ('error ' )->render (), 404 );
51
+ }
52
+
48
53
return parent ::render ($ request , $ e );
49
54
}
55
+
56
+ /**
57
+ * Check whether is not found exception.
58
+ *
59
+ * @param Exception $ex
60
+ * @return bool
61
+ */
62
+ protected function isNotFound (Exception $ ex )
63
+ {
64
+ return $ ex instanceof NotFoundHttpException
65
+ || $ ex instanceof ModelNotFoundException;
66
+ }
50
67
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Views file for errors handler.
4
+ *
5
+ * @author Vladimir Kuprienko <vldmr.kuprienko@gmail.com>
6
+ */
7
+ ?>
8
+ <h1>404</h1>
9
+ <p>Page not found.</p>
You can’t perform that action at this time.
0 commit comments