#898 – Using Code Snippets to Implement a Custom Exception Type

Visual Studio includes a code snippet that makes it easier to implement a custom exception type.

To add a custom exception type using a code snippet, start by adding a new class file to your project and naming it to match your exception type.




In the new class, delete the class definition, so that all that remains in the file is a namespace definition.



Create a new blank line within the namespace definition.  Begin typing the word “exception” and look for the icon in the Intellisense dropdown that indicates a code snippet.



Press the TAB key twice so that the code snippet is inserted.  The definition of a new class that derives from Exception will be inserted.



While the name of the new class is highlighted, type the name of your new exception type and press TAB.  The new exception type name will be inserted where appropriate.




About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

One Response to #898 – Using Code Snippets to Implement a Custom Exception Type

  1. Pingback: Dew Drop – July 30, 2013 (#1,595) | 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 )

Facebook photo

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

Connecting to %s

%d bloggers like this: