#898 – Using Code Snippets to Implement a Custom Exception Type
July 30, 2013 1 Comment
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.