File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -183,7 +183,7 @@ protected function genericResponse(Throwable $exception)
183183
184184 $ response = $ this ->newResponseArray ();
185185
186- array_walk_recursive ($ response , function (&$ value , $ key ) use ($ exception , $ replacements ) {
186+ array_walk_recursive ($ response , function (&$ value , $ key ) use ($ replacements ) {
187187 if (Str::startsWith ($ value , ': ' ) && isset ($ replacements [$ value ])) {
188188 $ value = $ replacements [$ value ];
189189 }
@@ -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+ } elseif ($ 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