litert:: ErrorStatusBuilder
#include <litert_macros.h>
A helper class for building and handling error statuses.
Summary
This class can be implicitly converted to either a LiteRtStatus or a litert::Expected holding an error. This allows it to be used with the LITERT_RETURN_IF_ERROR and LITERT_ASSIGN_OR_RETURN macros.
When a C++ error with a message is converted to a LiteRtStatus, the message is logged (as an error by default). The log level can be customized with the Log*() methods.
The error message can be extended with additional information using the << operator.
Constructors and Destructors |
|
|---|---|
ErrorStatusBuilder(T && error, litert::SourceLocation loc)
|
|
ErrorStatusBuilder(litert::Error error, litert::SourceLocation loc)
|
Public static functions |
|
|---|---|
AsError(T && value)
|
|
ForwardWrappedValue(Expected< T > & e)
|
T &&
|
ForwardWrappedValue(Expected< T & > & e)
|
T &
|
ForwardWrappedValue(absl::StatusOr< T > & e)
|
T &&
|
ForwardWrappedValue(absl::StatusOr< T & > & e)
|
T &
|
InvalidArgument(litert::SourceLocation loc)
|
|
IsError(T && value)
|
constexpr bool
|
WrongVersion(litert::SourceLocation loc)
|
|
Public functions |
|
|---|---|
Log(LiteRtLogSeverity log_level) noexcept
|
Sets the log level used when converting to a
LiteRtStatus. |
LogError() noexcept
|
Sets the log level to
error for conversion to a LiteRtStatus. |
LogInfo() noexcept
|
Sets the log level to
info for conversion to a LiteRtStatus. |
LogVerbose() noexcept
|
Sets the log level to
verbose for conversion to a LiteRtStatus. |
LogWarning() noexcept
|
Sets the log level to
warning for conversion to a LiteRtStatus. |
NoLog() noexcept
|
Prevents logging any message when converting to a
LiteRtStatus. |
PrintLog() const noexcept
|
void
|
operator LiteRtStatus() const noexcept
|
|
operator absl::Status() const noexcept
|
|
operator absl::StatusOr< T >() const noexcept
|
|
operator litert::Expected< T >() const noexcept
|
|
operator<<(T && val)
|
Appends data to the error message.
|
Public static functions
AsError
litert::Error AsError( T && value )
ForwardWrappedValue
T && ForwardWrappedValue( Expected< T > & e )
ForwardWrappedValue
T & ForwardWrappedValue( Expected< T & > & e )
ForwardWrappedValue
T && ForwardWrappedValue( absl::StatusOr< T > & e )
ForwardWrappedValue
T & ForwardWrappedValue( absl::StatusOr< T & > & e )
InvalidArgument
ErrorStatusBuilder InvalidArgument( litert::SourceLocation loc )
IsError
constexpr bool IsError( T && value )
WrongVersion
ErrorStatusBuilder WrongVersion( litert::SourceLocation loc )
Public functions
ErrorStatusBuilder
ErrorStatusBuilder( T && error, litert::SourceLocation loc )
ErrorStatusBuilder
ErrorStatusBuilder( litert::Error error, litert::SourceLocation loc )
Log
ErrorStatusBuilder & Log( LiteRtLogSeverity log_level ) noexcept
Sets the log level used when converting to a LiteRtStatus.
LogError
ErrorStatusBuilder & LogError() noexcept
Sets the log level to error for conversion to a LiteRtStatus.
LogInfo
ErrorStatusBuilder & LogInfo() noexcept
Sets the log level to info for conversion to a LiteRtStatus.
LogVerbose
ErrorStatusBuilder & LogVerbose() noexcept
Sets the log level to verbose for conversion to a LiteRtStatus.
LogWarning
ErrorStatusBuilder & LogWarning() noexcept
Sets the log level to warning for conversion to a LiteRtStatus.
NoLog
ErrorStatusBuilder & NoLog() noexcept
Prevents logging any message when converting to a LiteRtStatus.
PrintLog
void PrintLog() const noexcept
operator LiteRtStatus
operator LiteRtStatus() const noexcept
operator absl::Status
operator absl::Status() const noexcept
operator absl::StatusOr< T >
operator absl::StatusOr< T >() const noexcept
operator litert::Expected< T >
operator litert::Expected< T >() const noexcept