[#absl-BadStatusOrAccess] = xref:absl.adoc[absl]::BadStatusOrAccess :relfileprefix: ../ :mrdocs: Exception thrown when accessing the value of an invalid `StatusOr`. == Synopsis Declared in `<absl/status/statusor.h>` [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::StatusOr<T>` object that does not contain a value. This behavior is analogous to that of `std::bad_optional_access` in the case of accessing an invalid `std::optional` value. Example: try { absl::StatusOr<int> v = FetchInt(); DoWork(v.value()); // Accessing value() when not "OK" may throw } catch (absl::BadStatusOrAccess& ex) { LOG(ERROR) << ex.status(); } == Base Classes [cols="1,4"] |=== | Name| Description | `std::exception` | Base class for all library exceptions. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:absl/BadStatusOrAccess/2constructor-05.adoc[`BadStatusOrAccess`] [.small]#[constructor]# | Constructors | xref:absl/BadStatusOrAccess/2destructor.adoc[`~BadStatusOrAccess`] [.small]#[destructor]# [.small]#[virtual]# | Destroys the exception object. | xref:absl/BadStatusOrAccess/operator_assign-0f.adoc[`operator=`] | Assignment operators | xref:absl/BadStatusOrAccess/status.adoc[`status`] | Returns the associated error status. | xref:absl/BadStatusOrAccess/what.adoc[`what`] [.small]#[virtual]# | Returns the associated explanatory string. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#