[#BloombergLP-bsls-Assert]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bsls.adoc[bsls]::Assert
:relfileprefix: ../../
:mrdocs:

Utility that administers the process&hyphen;wide assertion&hyphen;failure handler&period;

== Synopsis

Declared in `&lt;bsls&lowbar;assert&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class Assert;
----

== Description

This &quot;utility&quot; class maintains a pointer containing the address of the current assertion&hyphen;failure handler function (of type `Assert&colon;&colon;ViolationHandler`) and provides methods to administer this function pointer&period; The `invokeHandler` method calls the currently&hyphen;installed failure handler&period; This class also provides a suite of standard failure&hyphen;handler functions that are suitable to be installed as the current `Assert&colon;&colon;ViolationHandler` function&period; Note that clients are free to install any of these (&quot;off&hyphen;the&hyphen;shelf&quot;) handlers, or to provide their own (&quot;custom&quot;) assertion&hyphen;failure handler functions when using this facility&period; Also note that assertion&hyphen;failure handler functions must not return (i&period;e&period;, they must `abort`, `exit`, `terminate`, `throw`, or hang)&period;

Finally, this class defines the constant strings that are passed as the `reviewLevel` to the `bsls&lowbar;review` handler for checks that failed in &quot;review mode&quot; (see &lcub;Assertion Modes&rcub;)&period;

== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bsls/Assert/Handler.adoc[`Handler`] 
| Alias for a legacy assertion&hyphen;failure handler function pointer&period;
| xref:BloombergLP/bsls/Assert/ViolationHandler-03.adoc[`ViolationHandler`] 
| Alias for a pointer to an assertion&hyphen;failure handler taking a violation&period;
|===


== Static Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bsls/Assert/abortUponReturningAssertionFailureHandler.adoc[`abortUponReturningAssertionFailureHandler`] 
| Return whether returning from an assertion&hyphen;failure handler must abort&period;
| xref:BloombergLP/bsls/Assert/failAbort.adoc[`failAbort`]  [.small]#[noreturn]#
| *DEPRECATED*&colon; Use `failByAbort` instead&period;
| xref:BloombergLP/bsls/Assert/failByAbort.adoc[`failByAbort`]  [.small]#[noreturn]#
| Abort after logging a message for the specified assertion violation&period;
| xref:BloombergLP/bsls/Assert/failBySleep.adoc[`failBySleep`]  [.small]#[noreturn]#
| Hang forever after logging a message for the specified violation&period;
| xref:BloombergLP/bsls/Assert/failByThrow.adoc[`failByThrow`]  [.small]#[noreturn]#
| Throw an exception describing the specified assertion violation&period;
| xref:BloombergLP/bsls/Assert/failSleep.adoc[`failSleep`]  [.small]#[noreturn]#
| *DEPRECATED*&colon; Use `failBySleep` instead&period;
| xref:BloombergLP/bsls/Assert/failThrow.adoc[`failThrow`]  [.small]#[noreturn]#
| *DEPRECATED*&colon; Use `failByThrow` instead&period;
| xref:BloombergLP/bsls/Assert/failureHandler.adoc[`failureHandler`] 
| Return the address of the currently installed assertion&hyphen;failure handler function if it is a `Handler` (and not a `ViolationHandler`)&semi; otherwise, return `NULL`&period;
| xref:BloombergLP/bsls/Assert/invokeHandler-082.adoc[`invokeHandler`] 
| `invokeHandler` overloads
| xref:BloombergLP/bsls/Assert/invokeHandlerNoReturn.adoc[`invokeHandlerNoReturn`]  [.small]#[noreturn]#
| Invoke the installed handler, aborting if it returns normally&period;
| xref:BloombergLP/bsls/Assert/lockAssertAdministration.adoc[`lockAssertAdministration`] 
| Disable all subsequent calls to `setFailureHandler`&period; Note that this method has no effect on the behavior of a `AssertFailureHandlerGuard` object&period;
| xref:BloombergLP/bsls/Assert/permitOutOfPolicyReturningFailureHandler.adoc[`permitOutOfPolicyReturningFailureHandler`] 
| DO NOT USE! It is a violation of Bloomberg policy to invoke this function without having prior authorization from senior management&period;
| xref:BloombergLP/bsls/Assert/setFailureHandler.adoc[`setFailureHandler`] 
| Make the specified handler `function` the current assertion&hyphen;failure handler&period; This method has no effect if the `lockAssertAdministration` method has been called&period;
| xref:BloombergLP/bsls/Assert/setViolationHandler.adoc[`setViolationHandler`] 
| Install the specified violation handler as the current assert handler&period;
| xref:BloombergLP/bsls/Assert/violationHandler-00.adoc[`violationHandler`] 
| Return the address of the currently installed assertion&hyphen;failure handler function&period;
|===


== Static Data Members

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bsls/Assert/k_LEVEL_ASSERT.adoc[`k&lowbar;LEVEL&lowbar;ASSERT`] 
| String identifier (&quot;DBG&quot;) for `BSLS&lowbar;ASSERT` failures&period;
| xref:BloombergLP/bsls/Assert/k_LEVEL_INVOKE.adoc[`k&lowbar;LEVEL&lowbar;INVOKE`] 
| String identifier (&quot;INV&quot;) for `BSLS&lowbar;ASSERT&lowbar;INVOKE` failures&period;
| xref:BloombergLP/bsls/Assert/k_LEVEL_OPT.adoc[`k&lowbar;LEVEL&lowbar;OPT`] 
| String identifier (&quot;OPT&quot;) for `BSLS&lowbar;ASSERT&lowbar;OPT` failures&period;
| xref:BloombergLP/bsls/Assert/k_LEVEL_SAFE.adoc[`k&lowbar;LEVEL&lowbar;SAFE`] 
| String identifier (&quot;SAF&quot;) for `BSLS&lowbar;ASSERT&lowbar;SAFE` failures&period;
| xref:BloombergLP/bsls/Assert/k_permitOutOfPolicyReturningAssertionBuildKey.adoc[`k&lowbar;permitOutOfPolicyReturningAssertionBuildKey`] 
| Build key used to enforce assertion handler return policy&semi; has value &quot;No&quot;&period; See &lcub;Assertion Handler Policy&rcub;&period;
|===


== Friends

[cols="1,4"]
|===
| Name| Description
| `xref:BloombergLP/bsls/AssertFailureHandlerGuard.adoc[BloombergLP::bsls::AssertFailureHandlerGuard]`
| Guard that temporarily replaces the assertion&hyphen;failure handler&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
