What should I do with the global exception?
See original GitHub issueWhether there is a mechanism like wfp’s DispatcherUnhandledException, my logic is that Project A refers to Project B, project B throws an exception, but not fatally just a hint. I want the program to continue running instead of exiting the program.
//when exception was throw
private void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
{
if (e.Exception is UserFriendlyException)
{
e.Handled = true;
Log.Logger.Error(e.Exception.Message);
MessageBox(e.Exception.Message);
//Other logic...
}
//Other logic...
}
Any suggestions or best practices?
I still don’t find useful information through search engines, which is the only relevant introduction I’ve found so far, but I don’t quite understand how to use this https://gitter.im/AvaloniaUI/Avalonia?at=5d833ca2a7a5cc473319c6ed https://www.reactiveui.net/docs/handbook/default-exception-handler/
Issue Analytics
- State:
- Created 3 years ago
- Reactions:6
- Comments:14 (8 by maintainers)
Top Results From Across the Web
Java Global Exception Handler
Learn how to globally handle all uncaught exceptions in your Java application.
Read more >Spring Boot Global Exception Handling
Spring boot provides classes such as ResponseEntity and HttpResponse which are used to set the response codes and can send the exception entity...
Read more >Spring Boot Global Exception Handler Examples
In exception handler methods, you can log the exception, redirect to user-friendly error pages, modify the response status code, ...
Read more >Is it good to use a "global" try catch exception handler in ...
Yes, add a global exception handler so exceptions can be logged, but don't use it to let the application stay alive.
Read more >Global Exception Handling in .NET 6
Global exception handling allows us to organize all exception handling logic in one place. Thus, we can improve the readability of the action ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
RxApp.DefaultExceptionHandler
allows you to catch any exceptions thrown from aReactiveCommand
,ObservableAsPropertyHelper
, and other stuff. It is recommended that in an Avalonia.ReactiveUI app you wrap the code that might throw exceptions into reactive commands (ReactiveUIICommand
implementation), see https://www.reactiveui.net/docs/handbook/commands/ This way your exceptions will tick through yourRxApp.DefaultExceptionHandler
and won’t cause the crash of your app.@olgaMuravjova since DispatcherUnhandledException or any other global unhandled exception handling, which prevents app from crashing, (and most possibly being trapped in invalid state) is considered as a bad practice, we don’t really plan to support it.
If you want to handle global errors, you can catch them in Program.Main method, log and close the app peacefully (restart or open report-error app if needed). Any other expected errors should be handled explicitly in place where they are expected.
Alternatively, as it was mentioned above, if you are using ReactiveUI with your app, this library actually provides DefaultExceptionHandler for exceptions inside of observables. Though in most cases it means that Observable pipeline now in error state and won’t work anymore.