Exception Specifications


The C++ language provides a facility for restricting the type of exceptions that may be thrown by a function. The declaration of a function may include a list of the types of exceptions that may be thrown (directly or indirectly) by the function. The syntax of such lists is shown below.

Syntax

exception_specification:
       throws (type_list)
 
type_list:
       type_name
       type_list, type_name

Notes

A simple example of an exception specification list is shown below.

void f() throws(exceptionA,exceptionB,exceptionC)
{
  ...
}

The following is true of exception specifications.