File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -203,11 +203,23 @@ protected function genericResponse(Throwable $exception)
203203 */
204204 protected function getStatusCode (Throwable $ exception )
205205 {
206+ $ statusCode = null ;
207+
206208 if ($ exception instanceof ValidationException) {
207- return $ exception ->status ;
209+ $ statusCode = $ exception ->status ;
210+ } else if ($ exception instanceof HttpExceptionInterface) {
211+ $ statusCode = $ exception ->getStatusCode ();
212+ } else {
213+ // By default throw 500
214+ $ statusCode = 500 ;
215+ }
216+
217+ // Be extra defensive
218+ if ($ statusCode < 100 || $ statusCode > 500 ) {
219+ $ statusCode = 500 ;
208220 }
209221
210- return $ exception instanceof HttpExceptionInterface ? $ exception -> getStatusCode () : 500 ;
222+ return $ statusCode ;
211223 }
212224
213225 /**
You can’t perform that action at this time.
0 commit comments