Utility that administers the process-wide assertion-failure handler.
Declared in <bsls_assert.h>
class Assert;
This "utility" class maintains a pointer containing the address of the current assertion-failure handler function (of type Assert::ViolationHandler) and provides methods to administer this function pointer. The invokeHandler method calls the currently-installed failure handler. This class also provides a suite of standard failure-handler functions that are suitable to be installed as the current Assert::ViolationHandler function. Note that clients are free to install any of these ("off-the-shelf") handlers, or to provide their own ("custom") assertion-failure handler functions when using this facility. Also note that assertion-failure handler functions must not return (i.e., they must abort, exit, terminate, throw, or hang).
Finally, this class defines the constant strings that are passed as the reviewLevel to the bsls_review handler for checks that failed in "review mode" (see {Assertion Modes}).
| Name | Description |
|---|---|
Handler | Alias for a legacy assertion-failure handler function pointer. |
ViolationHandler | Alias for a pointer to an assertion-failure handler taking a violation. |
| Name | Description |
|---|---|
abortUponReturningAssertionFailureHandler | Return whether returning from an assertion-failure handler must abort. |
failAbort [noreturn] | DEPRECATED: Use failByAbort instead. |
failByAbort [noreturn] | Abort after logging a message for the specified assertion violation. |
failBySleep [noreturn] | Hang forever after logging a message for the specified violation. |
failByThrow [noreturn] | Throw an exception describing the specified assertion violation. |
failSleep [noreturn] | DEPRECATED: Use failBySleep instead. |
failThrow [noreturn] | DEPRECATED: Use failByThrow instead. |
failureHandler | Return the address of the currently installed assertion-failure handler function if it is a Handler (and not a ViolationHandler); otherwise, return NULL. |
invokeHandler | invokeHandler overloads |
invokeHandlerNoReturn [noreturn] | Invoke the installed handler, aborting if it returns normally. |
lockAssertAdministration | Disable all subsequent calls to setFailureHandler. Note that this method has no effect on the behavior of a AssertFailureHandlerGuard object. |
permitOutOfPolicyReturningFailureHandler | DO NOT USE! It is a violation of Bloomberg policy to invoke this function without having prior authorization from senior management. |
setFailureHandler | Make the specified handler function the current assertion-failure handler. This method has no effect if the lockAssertAdministration method has been called. |
setViolationHandler | Install the specified violation handler as the current assert handler. |
violationHandler | Return the address of the currently installed assertion-failure handler function. |
| Name | Description |
|---|---|
k_LEVEL_ASSERT | String identifier ("DBG") for BSLS_ASSERT failures. |
k_LEVEL_INVOKE | String identifier ("INV") for BSLS_ASSERT_INVOKE failures. |
k_LEVEL_OPT | String identifier ("OPT") for BSLS_ASSERT_OPT failures. |
k_LEVEL_SAFE | String identifier ("SAF") for BSLS_ASSERT_SAFE failures. |
k_permitOutOfPolicyReturningAssertionBuildKey | Build key used to enforce assertion handler return policy; has value "No". See {Assertion Handler Policy}. |
| Name | Description |
|---|---|
BloombergLP::bsls::AssertFailureHandlerGuard | Guard that temporarily replaces the assertion-failure handler. |