User exceptions are illegal or inappropriate situations that are specific to a single application. Exceptions are categorized according to a class and subclass, which are long integer values that uniquely identify the exception. When an inappropriate situation occurs in your application, you will use the throw statement to generate an exception. When you throw an exception, you supply the class and subclass that identify the exception that occurred. You can also supply a message that describes the exception.
As an example, the following table lists some exceptions that can occur for the Real Estate Sales Manager sample application.
Exception |
Class |
Subclass |
---|---|---|
Invalid House ID |
22001 |
22001 |
Invalid Price |
22001 |
22002 |
Invalid Seller ID |
22002 |
22001 |
No Agent |
22002 |
22002 |
To make your code more readable, you may want to create constants for each exception class and subclass. |
If your application integrates with Microsoft Dynamics GP, the values you use for the class and subclass must be 22,000 or greater. |