Add Question

Default error 500 laravel

11 views 1 answers asked by Reno Paslah 2022-09-29 03:09:57

Bagaimana cara mengubah default error 500 pada laravel?


1 Answers

Pada App\Exceptions\Handler.php tambahkan code berikut :

public function render($request, Throwable $exception)
   {
       if (!env('APP_DEBUG', false)) {
           // jika ingin response dalam JSON
           return response()->json([
               'status' => '500',
               'message' => 'Server Error',
           ]);

           // jika ingin response dalam View
           // return response()->view("file_name");
       } else {
           return parent::render($request, $exception);
       }
   }

answered by Reno Paslah 2022-09-29 03:09:57