-
-
Notifications
You must be signed in to change notification settings - Fork 107
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
Added third option to Application::$catchExceptions #63
base: master
Are you sure you want to change the base?
Conversation
It gets even better when you use module-specific ErrorPresenters like I do. I'll try to send a PR with that later if this is merged. |
I'm not sure I understand. But I like the idea, that the BadRequestException won't show up in tracy but rather in ErrorPresenter even in debug mode. |
What about this solution to your problem:
|
By looking at the code I think that another solution may be possible – implement onError event listener in which you either enable or disable catchExceptions based on catched exception and debugMode. |
@JanTvrdik You missed the purpose of this PR entirely. I'm not looking for ways to do what the PR does without changing Nette, I already know several ways to do that without your help. I want to know if you like the idea of putting error handling in ErrorPresenter. If so I'd like to make it the recommended way for Nette, hence this PR to make it convenient for other people than myself. |
Ok, regarding this PR. I hate the magic |
Good. :-) I'm not really happy with the
Any suggestions? |
It would be nice to have clean solution for this problem. Sometimes I deal with it. |
@JanTvrdik What do you think about this? enumag@bef9392 |
6074ad2
to
81a1a34
Compare
51b53ed
to
d36f845
Compare
0c73a68
to
d07d7b3
Compare
ping @JanTvrdik |
I need this today 😄 But I still don't like your proposal. |
e3d05b3
to
929a242
Compare
426e735
to
c19ebdc
Compare
2b9da37
to
30d90f4
Compare
bf86204
to
c91f90a
Compare
57bd587
to
e908315
Compare
c5ecbda
to
ecb200c
Compare
I use a bunch of services to check whether the application is in state to run the request, if the use has privileges and so on. However these services are not supposed to handle the error correctly with a flashmessage and redirect, they only throw an exception (some specific descendant of BadRequestException).
I handle these exceptions in ErrorPresenter which works fine but I have some troubles with this in debug mode - I don't want to see these exceptions because they are kind of expected and I want to see if the ErrorPresenter handles them correctly. Therefore in debug mode I want to catch BadRequestException.
I consider this approach to be far better then the usual. When writing the application I don't repeat the flash messages and redirects everywhere (it get's even worse if I need to translate them - I need to inject the translator). Instead I just throw an exception and later add a line or two to ErrorPresenter. Presenters and controls are much cleaner because they focus on what they are supposed to do and don't have to deal with errors at all.
What do you think about this solution? I use it for about year or so and am really satisfied with it.