... switch (true) { case $exception instanceof ApplicationException: $code = Response::HTTP_BAD_REQUEST; // ... case $exception instanceof NotFoundHttpException: $code = Response::HTTP_NOT_FOUND; // ... // ... 82 lines } return response()->json( // ... $code ); } 16 public function render($request, \Exception $exception) { //... if ($exception instanceof ApplicationException) { return response()->json(//..., Response::HTTP_BAD_REQUEST); } //... if ($exception instanceof NotFoundHttpException) { return response()->json(//..., Response::HTTP_NOT_FOUND); } // ... 82 lines } No state, no aux vars needed here.