Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it okay to use Elmah instead of try/catch?

I have been using Elmah for an MVC application and my question is

Is it a bad practice to not write try catch statement when using Elmah?

like image 775
Arjun Shetty Avatar asked Dec 27 '22 17:12

Arjun Shetty


1 Answers

ELMAH is used to log unhandled exceptions. If you can handle the exception I would strongly suggest that you do.

If you still want to log the exceptions to ELMAH, you can do so:

try {
  ...
}
catch (Exception e) {
  Elmah.ErrorSignal.FromCurrentContext().Raise(e)
}
like image 175
Xharze Avatar answered Jan 11 '23 15:01

Xharze