#884 – Things You Might Do in an Exception Handler

You should typically only handle exceptions that you can do something about and where the cause of the exception is fully understood.

If you can fully recover from an exception, you might catch the exception and then report the problem to the user.  This makes sense if the user can do something differently to prevent the exception.  For example, you might:

  • Report invalid inputs and ask the user to enter valid data
  • Report IO failures due to a disk being full
  • Report IO failures due to the user not having the required permissions
  • Report that the user’s login credentials did not work
  • Retry an operation

In other cases, you might do something in response to an exception within a handler and then rethrow the exception.  You might:

  • Log the exception
  • Send an e-mail
  • Inform the user about an unrecoverable error
Advertisements

About Sean
Software developer in the Twin Cities area, passionate about .NET technologies. Equally passionate about my own personal projects related to family history and preservation of family stories and photos.

One Response to #884 – Things You Might Do in an Exception Handler

  1. Pingback: Dew Drop – July 10, 2013 (#1,582) | Alvin Ashcraft's Morning Dew

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: