-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Developer exception page #5476
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
Comments
It would be good to have this as a customisable page that follows the developer/application styling and possibly extended to post details of the client side exception back to a server api for logging/monitoring similar to application insights |
@grahamehorner That will be wrate, in order to see the logs... |
in the case of server side Blazor also it does not show any exception on UI but it does show exception on terminal window , for example if required services are not register it will be better to show exceptions in browser as well. for example in the case of default server side template , if we are removing |
If anyone is interested I found a workaround for handling exception : https://remibou.github.io/Exception-handling-in-Blazor/. It's not perfect as the extension point are minimal but still. |
Possible follow out from addressing #4047. Disposing components may throw and we allow it to bubble up. It would be useful to log and swallow these instead. |
Closing this in favor of #8613 which has a more concrete proposal about how this would work. |
Reopening to use for tracking |
@mkArtakMSFT I'll be providing some basic design notes for this, but am not assigning this issue to myself, because it's likely we'll need someone else to implement it. |
I'm not sure about the idea of not showing a single component of we encounter an unhandled exception. Won't this mean we will be letting an app continue to run despite not knowing how that component may have put some shared state in an unknown and potentially unsafe state? I don't think it's ever safe for a framework to decide it's safe to ignore an unexpected exception. |
OK, so a lot of things have changed since this issue and #8613 were first written. Mainly, we're much better at getting the right exception info to the browser now (correctly redacted in the case of server-side Blazor in production). In cases I'm aware of, the right information already goes to the browser console now, so the remaining matter is whether to display some additional UI for it. Thoughts
Design proposalI suggest a simplified version of @rynowak's original design. The main reason it can be simplified is that since then we've already solved various details about how error information gets from the server to the client. At a high level, I think we should respond to unhandled errors just by displaying a predefined Customizability:
Potential drawbacks:
Implementation suggestion
<div id="error-ui">
An unhandled error has occurred.
<a class='reload'>Reload</a>
<a class='dismiss'>Dismiss</a>
</div>
<div id="error-ui">
<environment include="Staging,Production">
An error has occurred. This application may no longer respond until reloaded.
</environment>
<environment include="Development">
An unhandled exception has occurred. See browser dev tools for details.
</environment>
<a class='reload'>Reload</a>
<a class='dismiss'>Dismiss</a>
</div>
Notice that we do not also add a full-screen overlay that grays/whites-out the rest of the UI, because that would interfere with debugging. The upgrade steps for people with 3.0 Blazor apps would be:
For anyone who doesn't do this, they retain their existing behavior of not having the feature, because the runtime code won't find |
cc @rynowak for any opinions. Do you think this retains the usefulness of your original suggestion? |
@rynowak could you confirm this design so I can get cracking? |
Would it be possible to capture all unhandled exception in a central place so the developer could decide what to do next. Currently we can only intercept console.error but that is not of much use. |
Sounds great, I think this is very thoughtful. Most of the feedback I thought of while reading this was already addressed. |
Hi @rborosak - some answers
We currently have no plans to provide a global way to silence exceptions. Blazor is stateful and it's important for security reasons that the user-agent can no longer send commands to the server if the program ends up in an unknown (faulted) state.
If I'm not mistake this feature addresses all of that. Let me know if I'm missing something.
Blazor already logs unhandled exceptions in the server logs. Is there something else you're looking for? |
@rynowak sorry... I'm talking about client side blazor.. when an unhandled exception is thrown, exception message and stack trace are printed in the console.. there is not much we can do with that.. I would like to have a global exception handler so I don't have to clutter my code with catch blocks
If DoSomeWorkAsync throws an exception I would like to handle it in a global exception handler and based od that exception do something (send exception to server where I can store it to database, maybe redirect user somewhere, maybe display some generic message, maybe nothing just swallow (ignore) exception and continue with work, etc..) and Blazor (client) side would not be in unknow state and would go to finally block, set DisplayLoadingIndicator to false and rerender the page and hide the loading indicator.. EDIT:
I would like to be able to provide my own implementation of HandleExcepetion.. WebAssemblyRenderer takes IServiceProvider as input parameter in constructor.. |
@rborosak The idea of being able to continue after a |
Or perhaps you just mean you want the framework to implicitly put a If so, this is something you can do yourself in a base class. Create your own component base class that overrides |
In any case, the idea of a global exception handler is separate from this issue, so for any further discussion about it, could you please file a separate issue? Thanks! |
@SteveSandersonMS Thanks, I don't want to continue after a throw.. I'm looking for something like AppDomain.UnhandledException Event in WPF There is a separate issue opened here |
Currently if there are any unhandled client-side .NET exceptions, Mono logs them to the console (which is reasonable for Mono to do). But within Blazor it would be nice to display the exception details in a friendly, formatted way within the browser UI itself, perhaps looking like an ASP.NET server-side developer exception page.
In the previous Blazor prototype this was implemented as a non-dismissable full-screen overlay. The way you made it go away was to change your code which (via live reloading) triggers a page refresh.Update: That's not true. It only did that for compilation errors. We probably will do the same thing again when we have live reload, but that's totally separate to this.As a separate work item, we should consider catching exceptions thrown by components during their known lifecycle methods (e.g., rendering). In this case we might choose not to display a full-screen error overlay, but instead display the affected component in some kind of "dead" state (e.g., exclamation mark icon). This is more suitable for production time errors where just because one component died doesn't mean you necessarily want the rest of your app to disappear.
The text was updated successfully, but these errors were encountered: