RE: Handling unhandled exceptions



Hi Bob,

The community members have provided good replies to you now. I wanted to
add some comment:

Just as Jeroen pointed out, as a library, your responsibility is throwing
the exception for bad condition. It is the application developer's
responsibility to set a top-level unhandled exception handler to report all
the information. If they did not do that, it is their problem. Your
responsibility is documenting all the possible or expected exceptions for
easy methods/routines in your library documents like what MSDN does.

Furthermore, I do not recommend you to use try...catch clause around all
the methods/routines, because this will eliminate the caller's chance to
fix the exception. For example, if one method is openning certain file and
the caller supplies a wrong path to your method. A FileNotFoundException
may be thrown from your method. The caller may use a try...catch for this
exception and notify the user with a dialog to supply a legal file path.
However, if you try...catch this in your library and just kill the
application, you did not give the caller any chance to fix it.

Is your library used in .Net Winform application? .Net has different
approaches to handle unhandled exceptions for console, Winform and Asp.net
applications. Winform's main GUI thread will use
Application.ThreadException event to handle the exception. So, if your
library is tested in .Net Winform,
AppDomain.CurrentDomain.UnhandledException event will not catch it. See the
article for more details:
"Unexpected Errors in Managed Applications"
http://msdn2.microsoft.com/en-us/magazine/cc188720.aspx

Hope it helps.

Best regards,
Jeffrey Tan
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@xxxxxxxxxxxxxx

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


.



Relevant Pages

  • Re: Handling unhandled exceptions
    ... Just as Jeroen pointed out, as a library, your responsibility is ... throwing the exception for bad condition. ... Microsoft Online Community Support ... Please feel free to let my manager know what you think of the ...
    (microsoft.public.dotnet.languages.vc)
  • RE: Backup & Monitoring not working!
    ... Error message in Windows Small Business Server 2003: ... Microsoft CSS Online Newsgroup Support ... This newsgroup only focuses on SBS technical issues. ... An unhandled exception occurred during the execution of the ...
    (microsoft.public.windows.server.sbs)
  • Re: DropDownList has SelectedValue which in invalid
    ... From your description you want to avoid getting the exception: ... 'ddlAssignedTo' has a SelectedValue which is invalid because it does not ... Microsoft Online Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: Cant open Websites With VS2008
    ... Faulting module name: SHELL32.dll, version: 6.1.7100.0, time stamp: 0x49eea6b3 ... If it is Vista or 2008, please open Visual Studio as administrator first. ... please we need the following log and exception ... Microsoft Online Community Support ...
    (microsoft.public.vsnet.general)
  • Re: Can you decrypt this?
    ... start diagnosiss later. ... The responsibility away from the operational ... partnership is the imagination that merges frantically. ... the advantage will pour in support of the lower ...
    (sci.crypt)