ExceptionHandler
class which is responsible for handling all exceptions thrown by your application.exception_handler
key.errors/500.html
, errors/404.html
, errors/403.html
error pages are rendered depending on error type.masonite.exception.SomeException
event will be fired.application/json
masonite.exception.SomeException
event will be fired.errors/500.html
, errors/404.html
, errors/403.html
) and rendering it.HTTPExceptionHandler
with the corresponding status code and the corresponding default error template if it exists in errors/
. (Note that in debug mode this template won't be rendered and the default Exceptionite error page will be rendered instead).errors/404.html
, errors/403.html
and errors/500.html
. Those views can be customized.is_http_exception=True
to it and by defining the get_response()
, get_status()
and get_headers()
methods:errors/401.html
in the default project views folder and will render it with a 401
status code. The content of get_response()
method will be passed as the message
context variable to the view.get_response()
method with a 401
status code.get_response()
method to it. This method will be given as first argument of response.view()
, so that you can render simple string or your own view template.get_response()
method and here it will render as a string containing the message raised.get_status()
method to the exception.handle()
method that Masonite will call when a specific exception is thrown by the application.ZeroDivisionError
exceptions that could be thrown by your application. It will look like this:{exception_name}Handler
. You can do this in your Kernel file.ZeroDivisionError
we would create a binding that looks like this:Kernel.py
.ZeroDivisionError
, Masonite will use your handler rather than Masonite's own exception handlers.masonite.exception.{TheExceptionType}
is fired, allowing to run any custom logic.