Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
arene::base::filesystem::error_code Class Reference

A class representing a filesystem error value. Intended to be a wrapper around errno. More...

Public Types

using raw_error_code = int
 Raw error code type.
 

Public Member Functions

 error_code () noexcept
 Construct with no error.
 
constexpr error_code (raw_error_code const error) noexcept
 Construct with a specified error value.
 
void clear () noexcept
 clear the error
 
auto message () const noexcept -> error_string
 Get a message describing the error.
 
 operator bool () const noexcept
 Check if the error is non-zero, which represents there is an error.
 
ARENE_NORETURN void throw_error () const
 Raise an exception produced from the error.
 
ARENE_NORETURN void throw_error_with_prefix (null_terminated_string_view const message_prefix) const
 Raise an exception produced from the error with a descriptive message.
 
constexpr auto value () const noexcept -> raw_error_code
 Get the stored error value.
 

Static Public Member Functions

static auto from_errno () noexcept -> error_code
 Create an instance from the current state of errno.
 

Detailed Description

A class representing a filesystem error value. Intended to be a wrapper around errno.

Member Typedef Documentation

◆ raw_error_code

Raw error code type.

Constructor & Destructor Documentation

◆ error_code() [1/2]

arene::base::filesystem::error_code::error_code ( )
inlinenoexcept

Construct with no error.

Postcondition
value() == 0

◆ error_code() [2/2]

arene::base::filesystem::error_code::error_code ( raw_error_code const error)
inlineexplicitconstexprnoexcept

Construct with a specified error value.

Parameters
errorThe error value to construct from
Postcondition
value() == error

Member Function Documentation

◆ clear()

void arene::base::filesystem::error_code::clear ( )
inlinenoexcept

clear the error

Postcondition
value() == 0
static_cast<bool>(*this) == false

◆ from_errno()

auto arene::base::filesystem::error_code::from_errno ( ) -> error_code
staticnoexcept

Create an instance from the current state of errno.

Returns
An error_code with value() equal to the old value of errno
Postcondition
Sets errno to 0

◆ message()

auto arene::base::filesystem::error_code::message ( ) const -> error_string
noexcept

Get a message describing the error.

Returns
An error_string with a description of the error indicated by the stored error value

◆ operator bool()

arene::base::filesystem::error_code::operator bool ( ) const
inlineexplicitnoexcept

Check if the error is non-zero, which represents there is an error.

Returns
true if the error value is non-zero
false otherwise.

◆ throw_error()

ARENE_NORETURN void arene::base::filesystem::error_code::throw_error ( ) const

Raise an exception produced from the error.

Exceptions
std::system_errorcontaining the error code

◆ throw_error_with_prefix()

ARENE_NORETURN void arene::base::filesystem::error_code::throw_error_with_prefix ( null_terminated_string_view const message_prefix) const

Raise an exception produced from the error with a descriptive message.

Parameters
message_prefixA string to prefix the error message with
Exceptions
std::system_errorcontaining the error code prefixed with the given message.

◆ value()

auto arene::base::filesystem::error_code::value ( ) const -> raw_error_code
inlineconstexprnoexcept

Get the stored error value.

Returns
The stored error value

The documentation for this class was generated from the following files: