cpp/language/function-try-block

Establishes an exception handler around the body of a function.

Syntax
The function-try-block is one of the alternative syntax forms for, which is a part of.

Explanation
A function-try-block associates a sequence of catch clauses with the entire function body, and with the (if used in a constructor) as well. Every exception thrown from any statement in the function body, or (for constructors) from any member or base constructor, or (for destructors) from any member or base destructor, transfers control to the the same way an exception thrown in a regular  would.

Before any catch clauses of a function-try-block on a constructor are entered, all fully-constructed members and bases have already been destroyed.

Before any catch clauses of a function-try-block on a destructor are entered, all bases and non-variant members have already been destroyed.

The behavior is undefined if the catch-clause of a function-try-block used on a constructor or a destructor accesses a base or a non-static member of the object.

Every catch-clause in the function-try-block for a constructor must terminate by throwing an exception. If the control reaches the end of such handler, the current exception is automatically rethrown as if by. The return statement is not allowed in any catch clause of a constructor's function-try-block.

Reaching the end of a catch clause for a function-try-block on a destructor also automatically rethrows the current exception as if by, but a return statement is allowed.

For all other functions, reaching the end of a catch clause is equivalent to if the function's return type is (possibly cv-qualified), otherwise the behavior is undefined.