Best open source C # tool for exception handling

Can anyone point me to a list of open source projects dedicated to exception handling? Or the best tool among them?

Update . I would like to use it with a winform application. I would like to catch once and for all 3 or 4 kinds of exceptions that are happening in my data access stack. Then pass them onto the gui stack and show them to the user in a message box or whatever.

+2


source to share


6 answers


Here's ELMAH , which is for logging errors in web applications. It may or may not be useful to you - you haven't specified anything about what you want, or you need it for a web app, WinForms, WPF, etc.



+4


source


You can use the Application_ThreadException event to handle all exceptions globally. You can find more about it here

[STAThread] static void Main() {
  Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
  Application.Run(new Form1());
}

private void button1_Click(object sender, System.EventArgs e) {
  throw new Exception("Whoops");
}

private static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e) {
  MessageBox.Show(e.Exception.Message);
}

      

To show user friendly exception messages, you can check this codeproject article .



You can use the Application Block to handle exceptions from Microsoft. The MSDN introduction says:

The Enterprise Library Exception Handling Application Block enables policy developers and policymakers to create a consistent strategy for handling exceptions that occur across all architectural layers of an enterprise application. He does it like this:

  • It supports exception handling across all architectural layers of the application and is not limited to service interface boundaries.
  • It allows you to define and maintain exception handling policies at the administrative level so that policy developers, who might be system administrators as well as developers, can determine how to handle exceptions. They can maintain and modify the rules that control exception handling without modifying the code of the application block.
  • It provides commonly used exception handling features such as the ability to log exception information, the ability to hide sensitive information by replacing the original exception with another exception, and the ability to maintain contextual information for an exception by wrapping the original exception inside another exception. These functions are encapsulated in .NET classes with exception handlers.
  • It can combine exception handlers to get the desired response to the exception, for example, log information about the exception and then replace the original exception with another.
  • This allows developers to create their own exception handlers.
  • It processes the exception handlers sequentially. This means that handlers can be used in multiple places within and between applications.
+4


source


You can take a look at Exceptioneer - although not open source, it is free.

+3


source


This is the best I've seen / used. I modified it to fit into the application I support, and the results were great.

I got scared of a lot of developers by telling them which line of code has the problem.

Jeff Atwood Exception Handler

+1


source


I would like to use it with a winform application. I would like to catch once and for all 3 or 4 kinds of exceptions that are happening in my data access stack. Then pass them onto the gui stack and show them to the user in a message box or whatever.

0


source


I recently started using NLog , which is a great way to log exceptions and generally run your application. You can create some really readable log files / emails / etc. thus.

0


source







All Articles