I specifically ask how to handle invisible exceptions, rather than unhandled exceptions. This question also differs from this question , which asks how to improve asynchronous start and forget methods, and not how to handle invisible exceptions, although they are related.
Unusual exceptions are a type caused by the following example, taken from here :
Task op1 = FooAsync(); Task op2 = BarAsync(); await op1; await op2;
As a rule, I try to avoid this situation, but if this happens, I do not want my website to come out unexpectedly, and I do not want these exceptions to be swallowed silently. At least I want to process them in one place and register them. I do not want to use elmah.
Now I think we can do something like this example from here :
TaskScheduler.UnobservedTaskException += (sender, e) => { Console.WriteLine("Saving the day! This exception would have been unobserved: {0}", e.Exception); e.SetObserved(); };
But, my questions are: -
- Where to put this, can it go to Application_Start ()?
- Will these subtle exceptions break through in Application_Error ()? If so, how do you identify them or stop them from appearing in Application_Error.
This question is similar, but there is no satisfactory answer / explanation.
acarlon Aug 29 '13 at 3:42 on 2013-08-29 03:42
source share