/** * Render an exception into an HTTP response. * * @param \Illuminate\Http\Request $request * @param \Exception $exception * @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse */ public function render($request, Exception $exception) { if (env('APP_DEBUG')) { return parent::render($request, $exception); } $status = Response::HTTP_INTERNAL_SERVER_ERROR; if ($exception instanceof HttpResponseException) { $status = Response::HTTP_INTERNAL_SERVER_ERROR; } elseif ($exception instanceof ModelNotFoundException) { $status = 200; // Ez azrt 200, mert különben nem megy át a json. } elseif ($exception instanceof MethodNotAllowedHttpException) { $status = Response::HTTP_METHOD_NOT_ALLOWED; $exception = new MethodNotAllowedHttpException([], 'HTTP_METHOD_NOT_ALLOWED', $exception); } elseif ($exception instanceof NotFoundHttpException) { $status = $exception->getStatusCode(); //$exception = new NotFoundHttpException('HTTP_NOT_FOUND', $exception); } elseif ($exception instanceof AuthorizationException) { $status = Response::HTTP_FORBIDDEN; $exception = new AuthorizationException('HTTP_FORBIDDEN', $status); } elseif ($exception instanceof \Dotenv\Exception\ValidationException && $exception->getResponse()) { $status = Response::HTTP_BAD_REQUEST; $exception = new \Dotenv\Exception\ValidationException('HTTP_BAD_REQUEST', $status, $exception); } elseif ($exception) { $status = 200; // $exception = new HttpException($status, 'HTTP_INTERNAL_SERVER_ERROR'); } // dump($exception); // return "hello"; return response()->json([ 'success' => false, 'status' => $status, 'message' => $exception->getMessage() ], $status); // Itt mindig 200-at kell visszaadni }