Skip to content

Instantly share code, notes, and snippets.

@salarmehr
Last active February 12, 2020 05:45
Show Gist options
  • Save salarmehr/b9a736e4ab2d88a97d374fe68e2eb608 to your computer and use it in GitHub Desktop.
Save salarmehr/b9a736e4ab2d88a97d374fe68e2eb608 to your computer and use it in GitHub Desktop.
Force Laravel to send regular exception on Ajax call instead of JSON excption

vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php:187

        return $request->expectsJson()
                    ? $this->prepareJsonResponse($request, $e)
                    : $this->prepareResponse($request, $e);

replace or extend the function with

        return $this->prepareResponse($request, $e);                 
        \\return $request->expectsJson()
        \\            ? $this->prepareJsonResponse($request, $e)
        \\           : $this->prepareResponse($request, $e);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment