Global exception handling in .NET

De openkb
Aller à : Navigation, rechercher

Sommaire

Questions

The whole concept of exception handling is giving me headaches. Currently, what I want to do is to handle specific exceptions that I am positively sure I can handle. On the other hand, I want to terminate the application if an exception that I dont know how to handle is thrown. When I place try-catch blocks in my source code, it looks ugly because there are many of those. Is there a global exception handling mechanism like an event that is fired once an unhandled exception is thrown? That way I can display an error message to the user and terminate the application instead of reiterating this process over and over throughout my source code.

P.S. I want to terminate the application in such a scenario because I am afraid the program might begin functioning improperly once an unhandled exception is thrown.

Answers

At least in C# you can assign a global "unhandled exception handler". To do this, you d assign a new handler to AppDomain.CurrentDomain.UnhandledException.

Source

License : cc by-sa 3.0

http://stackoverflow.com/questions/3210850/global-exception-handling-in-net

Related

Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Outils