File tree Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -71,13 +71,13 @@ public function render($request, $exception)
7171 $ response = new RestResponse ();
7272
7373 switch (true ) {
74- case $ exception instanceof NotFoundHttpException:
7574 case $ exception instanceof ModelNotFoundException:
7675 $ response ->addError (__ ('messages.not_found ' ))->missing ();
7776 break ;
7877 // These has custom message, that message could be displayed in production.
7978 case $ exception instanceof EntityNotFoundExceptionEloquent:
8079 case $ exception instanceof EntityNotFoundException:
80+ case $ exception instanceof NotFoundHttpException:
8181 $ response ->addError ($ exception ->getMessage ())->missing ();
8282 break ;
8383
@@ -108,8 +108,9 @@ public function render($request, $exception)
108108 case $ exception instanceof InvalidSignatureException:
109109 $ response ->addError ($ exception ->getMessage ())->forbidden ();
110110 break ;
111+
111112 case $ exception instanceof HttpException:
112- $ response ->addError ($ exception ->getMessage ())->forbidden ( );
113+ $ response ->addError ($ exception ->getMessage ())->code ( $ exception -> getStatusCode () );
113114 break ;
114115
115116 default :
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ public function test_404_by_generated_by_framework()
5454 {
5555 $ response = $ this ->handler ->render ($ this ->request , new NotFoundHttpException ('This message is not visible ' ));
5656 $ this ->assertInstanceOf (JsonResponse::class, $ response );
57- $ this ->assertEquals ($ response ->getData ()->errors [0 ], __ ( ' messages.not_found ' ) );
57+ $ this ->assertEquals ($ response ->getData ()->errors [0 ], ' This message is not visible ' );
5858 $ this ->assertEquals ($ response ->getStatusCode (), 404 );
5959
6060 $ response = $ this ->handler ->render ($ this ->request , new ModelNotFoundException ('This message is not visible ' ));
@@ -161,7 +161,7 @@ public function test_can_inject_custom_handler_but_handler_will_continue_handle(
161161
162162 $ response = $ this ->handler ->render ($ this ->request , new NotFoundHttpException ('This message is not visible ' ));
163163 $ this ->assertInstanceOf (JsonResponse::class, $ response );
164- $ this ->assertEquals ($ response ->getData ()->errors [0 ], __ ( ' messages.not_found ' ) );
164+ $ this ->assertEquals ($ response ->getData ()->errors [0 ], ' This message is not visible ' );
165165 $ this ->assertEquals ($ response ->getStatusCode (), 404 );
166166 }
167167}
You can’t perform that action at this time.
0 commit comments