Exception thrown when accessing the value of an invalid StatusOr.

Synopsis

Declared in <absl/status/statusor.h>

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

Name

Description

std::exception

Base class for all library exceptions.

Member Functions

Name

Description

BadStatusOrAccess [constructor]

Constructors

~BadStatusOrAccess [destructor] [virtual]

Destroys the exception object.

operator=

Assignment operators

status

Returns the associated error status.

what [virtual]

Returns the associated explanatory string.

Created with MrDocs