Rethrowing Exceptions (C++)

From RAD Studio
Jump to: navigation, search

Go Up to Standard C++ Exception Handling

In some cases, an exception handler may process an exception, then either rethrow the same exception or throw a different exception.

If the handler wants to rethrow the current exception, it can just use the throw statement with no parameters. This instructs the compiler/RTL to take the current exception object and throw it again. For example:

catch (EIntegerRange &rangeErr) {
	// Code here to do local handling for the exception
	throw; // rethrow the exception
}

If the handler wants to throw a different exception, it just uses the throw statement in the normal way.

See Also