[#absl-BadStatusOrAccess]
= xref:absl.adoc[absl]::BadStatusOrAccess
:relfileprefix: ../
:mrdocs:

Exception thrown when accessing the value of an invalid `StatusOr`&period;

== Synopsis

Declared in `&lt;absl&sol;status&sol;statusor&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class BadStatusOrAccess
    : public std::exception
----

== Description

This class defines the type of object to throw (if exceptions are enabled), when accessing the value of an `absl&colon;&colon;StatusOr&lt;T&gt;` object that does not contain a value&period; This behavior is analogous to that of `std&colon;&colon;bad&lowbar;optional&lowbar;access` in the case of accessing an invalid `std&colon;&colon;optional` value&period;

Example&colon;

try &lcub; absl&colon;&colon;StatusOr&lt;int&gt; v &equals; FetchInt()&semi; DoWork(v&period;value())&semi; &sol;&sol; Accessing value() when not &quot;OK&quot; may throw &rcub; catch (absl&colon;&colon;BadStatusOrAccess&amp; ex) &lcub; LOG(ERROR) &lt;&lt; ex&period;status()&semi; &rcub;

== Base Classes

[cols="1,4"]
|===
| Name| Description
| `std::exception`
| Base class for all library exceptions&period;
|===

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:absl/BadStatusOrAccess/2constructor-05.adoc[`BadStatusOrAccess`]         [.small]#[constructor]#
| Constructors
| xref:absl/BadStatusOrAccess/2destructor.adoc[`&#126;BadStatusOrAccess`] [.small]#[destructor]# [.small]#[virtual]#
| Destroys the exception object&period;
| xref:absl/BadStatusOrAccess/operator_assign-0f.adoc[`operator&equals;`] 
| Assignment operators
| xref:absl/BadStatusOrAccess/status.adoc[`status`] 
| Returns the associated error status&period;
| xref:absl/BadStatusOrAccess/what.adoc[`what`]  [.small]#[virtual]#
| Returns the associated explanatory string&period;
|===



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