-
-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Throw exception if route is not found when in debug mode and add http error views #506
Conversation
@josephmancuso here is my proposal. ready to discuss it. |
I made some updates to the PR it should be good now. We can take many approaches to do this of course... I tried many things and choosed one way. You can look closely at the updates in ExceptionHandler which is making the switch between debug and not debug and the HttpExceptionHandler which is there to give developers a way to customize things easily (adding call to sentry, or logging stuff or doing anything they want). |
Tested this with APP_DEBUG false and got this error:
|
I believe this is due to the fact that I don't have a templates/errors/500.html page |
Everything else seems to work fine |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just need to fix the assumption that the templates errors directory exists
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just need to fix the assumption that the templates errors directory exists
Actually it's more a problem in the view class. The exists() method is not totally right and add_namespaced_location() works for package but does not work for views inside the project itself. We could check that later. Now this works when templates exists or not. |
I also added default errors pages in cookie-cutter : MasoniteFramework/cookie-cutter#35 |
Add debug mode (fix #512)
APP_ENV
env variable and defined inconfig/application.py
so it can be accessed withconfig("application.debug")
application.is_debug()
When debug mode is on
all exceptions are rendered with exceptionite (except for application/json) fix #487.
![image](https://user-images.githubusercontent.com/9897999/150685931-77432afd-0379-43d3-80ed-ffce4f6be681.png)
When debug mode is off
errors/{code}.html
. If view does not exist the message is rendered directly as a string with the correct status.is_http_exception
flag will be rendered like above.Customization
HTTPExceptionHandler
to do what you want.Tests helpers
debugMode
context manager to change debug mode locally during a testenv
context manager to change env locally during a testTinker command