set_unexpected

De RAD Studio
Aller à : navigation, rechercher

Remonter à Except.h - Index


Header File

except.h

Syntax

typedef void ( * unexpected_handler )();

unexpected_handler set_unexpected(unexpected_handler unexpected_func);

Description

set_unexpected lets you install a function that defines the program's behavior when a function throws an exception not listed in its exception specification. The actions are defined in unexpected_func, which is declared to be a function of type unexpected_handler. An unexpected_handler type, defined in except.h, is a function that takes no arguments, and returns void.

By default, an unexpected exception causes unexpected to be called. If is defined, it is subsequently called by unexpected. Program control is then turned over to the user-defined unexpected_func. Otherwise, terminate is called.

Return Value

The previous function given to set_unexpected will be the return value.

The definition of unexpected_func must not return to its caller, the unexpected function. An attempt to return to the caller results in undefined program behavior.

unexpected_func can also call abort, exit, or terminate.