-
-
Notifications
You must be signed in to change notification settings - Fork 547
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
Handling custom block initialization exceptions #1893
Comments
Define what you mean by “loading a page”. Are you using Razor Pages or MVC? I’ve looked at the PageService and there shouldn’t be any try/catches on service level for initialization errors. |
I'm using Razor pages. If you take the Piranha Razor pages template app and add that custom block to a page, then when you navigate to the page containing the block (not in the manager) that's when it returns an error that appears to bypass any exception/error handling middleware. |
The way I'm handling this is to catch all exceptions from custom block constructors, this is a decent approach as it's then possible to display the error message in the display of the block itself rather than crashing the services, but for those exceptions that are missed for whatever reason it would be much better if the standard processing functioned normally. |
If a custom block throws an exception on initialization, the exception appears to completely bypass any middleware exception handling.
E.g. given this custom block
Add this block to a page and then loading the page.
In Development mode the developer exception page is not displayed.
In Production mode
UseExceptionHandler("/Error")
does not take effect.In both cases a plain 500 status code is returned resulting in the browser default error page, which is not what we want.
Does anyone know why this should be happening or what we should do to reinstate the behaviour of the exception handling middleware?
The text was updated successfully, but these errors were encountered: