idfxx 1.0.0
Modern C++23 components for ESP-IDF
Loading...
Searching...
No Matches
error.hpp File Reference

IDFXX error handling. More...

#include <expected>
#include <functional>
#include <string>
#include <system_error>
#include <utility>

Go to the source code of this file.

Classes

class  idfxx::error_category
 Error category for IDFXX and ESP-IDF error codes. More...
 

Namespaces

namespace  idfxx
 

Typedefs

typedef int esp_err_t
 
template<typename T >
using idfxx::result = std::expected< T, std::error_code >
 result type wrapping a value or error code.
 

Enumerations

enum class  idfxx::errc : esp_err_t {
  idfxx::fail = -1 ,
  idfxx::no_mem = 0x101 ,
  idfxx::invalid_arg = 0x102 ,
  idfxx::invalid_state = 0x103 ,
  idfxx::invalid_size = 0x104 ,
  idfxx::not_found = 0x105 ,
  idfxx::not_supported = 0x106 ,
  idfxx::timeout = 0x107 ,
  idfxx::invalid_response = 0x108 ,
  idfxx::invalid_crc = 0x109 ,
  idfxx::invalid_version = 0x10A ,
  idfxx::invalid_mac = 0x10B ,
  idfxx::not_finished = 0x10C ,
  idfxx::not_allowed = 0x10D
}
 IDFXX error codes. More...
 

Functions

const error_categoryidfxx::default_category () noexcept
 Returns a reference to the IDFXX error category singleton.
 
std::error_code idfxx::make_error_code (errc e) noexcept
 Creates a std::error_code from an idfxx::errc value.
 
std::error_code idfxx::make_error_code (esp_err_t e) noexcept
 Creates a std::error_code from a general esp_err_t value.
 
template<typename E >
requires std::is_error_code_enum_v<E>
constexpr std::unexpected< std::error_code > idfxx::error (E e) noexcept
 Creates an unexpected error from an error code enum.
 
template<typename E >
requires std::is_error_condition_enum_v<E>
constexpr std::unexpected< std::error_code > idfxx::error (E e) noexcept
 Creates an unexpected error from an error condition enum.
 
std::unexpected< std::error_code > idfxx::error (esp_err_t e) noexcept
 Creates an unexpected error from an esp_err_t value.
 
std::unexpected< std::error_code > idfxx::error (std::error_code ec) noexcept
 Creates an unexpected error from a std::error_code.
 
result< void > idfxx::wrap (esp_err_t e)
 Wraps an esp_err_t into a result<void>.
 
template<typename T >
idfxx::unwrap (result< T > result)
 Throws a std::system_error if the result is an error.
 
template<>
void idfxx::unwrap (result< void > result)
 
template<typename T , typename Callback >
requires std::invocable<Callback, std::error_code> && std::same_as<std::invoke_result_t<Callback, std::error_code>, void>
void idfxx::abort_on_error (result< T > result, Callback &&on_error)
 Aborts the program if the result contains an error.
 
template<typename T >
void idfxx::abort_on_error (result< T > result)
 Aborts the program if the result contains an error.
 

Detailed Description

IDFXX error handling.

Definition in file error.hpp.