### Using Throw Macros

When your code encounters an exceptional situation, you should identify which subclass of IException best conveys the nature of the situation and then throw that exception using an appropriate throw macro. There are nine throw macros:

- ITHROW
- ITHROWGUIERROR
- ITHROWGUIERROR2
- ITHROWSYSTEMERROR
- ITHROWCLIBERROR
- ITHROWLIBRARYERROR
- ITHROWLIBRARYERROR1
- ITHROWERROR
- ITHROWERROR1

The ITHROW macro accepts as input an object of any IException subclass. It expands to add the location information to the instance, logs all instance data, and then throws the exception.

The ITHROWGUIERROR macro takes as its only argument the name of the GUI function that returned an error code. It calls the IGUIError::throwGUIError function, which creates an IGUIErrorInfo instance and uses it to create an IAccessError instance, adds location information, logs out the exception data, and throws the exception. The exception severity is set to recoverable. Only use this macro if the error information that is retrievable by the IGUIErrorInfo class is available.

The ITHROWGUIERROR2 macro takes three arguments (only use this macro if the error information that is retrievable by the IGUIErrorInfo class is available):

1. The name of the GUI function that returned an error code
2. One of the values of the IBaseErrorInfo::ExceptionType enumeration, which indicates the type of exception to be created
3. One of the values of the IException::Severity enumeration, which indicates the severity of the exception

The ITHROWSYSTEMERROR macro takes four arguments:

1. The error ID returned from the system function
2. The name of the system function that returned an error code
3. One of the values of the IBaseErrorInfo::ExceptionType enumeration, which indicates the type of exception to be created
4. One of the values of the IException::Severity enumeration, which indicates the severity of the exception

The INO_EXCEPTIONS_SUPPORT macro is provided in support of compilers that lack exception handling implementation. If it is defined, the ITHROW macro ends the program after capturing the location information and logging it, instead of throwing an exception. This macro may not work correctly on all compilers.

Interpreting Exceptions
Using Assertion Macros
Using try and catch
Rethrowing Exceptions
Deriving Your Own Exceptions
Tracing Exceptions

The Exceptions Mechanism
Using Exceptions