tcalc error definition. More...
#include <cerrno>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <exception>
#include <string>
#include <unordered_map>
#include <expected>
#include "tcalc/common.hpp"
Go to the source code of this file.
Classes | |
class | tcalc::error::Error |
Error class. More... | |
Macros | |
#define | _TCALC_EXPECTED_NS std |
#define | ret_err(expr) |
#define | unwrap_err(expr) |
#define | log_err(expr) |
#define | log_err_exit(expr) |
Typedefs | |
template<typename T > | |
using | tcalc::error::Result = _TCALC_EXPECTED_NS::expected< T, Error > |
Result type. | |
Enumerations | |
enum class | tcalc::error::Code : uint8_t { SYNTAX_ERROR , UNDEFINED_VAR , UNDEFINED_FUNC , MISMATCHED_ARGS , ZERO_DIVISION , RECURSION_LIMIT , FILE_NOT_FOUND } |
Error code. More... | |
Functions | |
TCALC_INLINE auto | tcalc::error::err (Code code, const std::string &message) noexcept |
Create an error. | |
TCALC_INLINE auto | tcalc::error::raw_err (Code code) noexcept |
Create a raw error with errno. | |
TCALC_INLINE auto | tcalc::error::err (Code code) noexcept |
Create an error with errno. | |
_TCALC_EXPECTED_NS::unexpected< Error > | tcalc::error::err (Code code, const char *fmt,...) noexcept |
Create an error with format. | |
template<typename T , typename... Args> | |
TCALC_INLINE auto | tcalc::error::ok (Args &&... args) noexcept |
Create a result with value. | |
template<> | |
TCALC_INLINE auto | tcalc::error::ok< void > () noexcept |
Create a result with void value. | |
Variables | |
const std::unordered_map< Code, std::string > | tcalc::error::CODE_NAMES |
tcalc error definition.
#define log_err | ( | expr | ) |
#define log_err_exit | ( | expr | ) |
#define ret_err | ( | expr | ) |
#define unwrap_err | ( | expr | ) |
using tcalc::error::Result = typedef _TCALC_EXPECTED_NS::expected<T, Error> |
Result type.
T | Return type. |
|
strong |
|
noexcept |
Create an error with errno.
code | Error code. |
|
noexcept |
Create an error with format.
code | Error code. |
fmt | Format string. |
args | Arguments. |
Create an error.
code | Error code. |
message | Error message. |
|
noexcept |
Create a result with value.
T | Return type. |
Args | Arguments to construct the value. |
args | Arguments to construct the value. |
|
noexcept |
Create a result with void value.
|
noexcept |
Create a raw error with errno.
code | Error code. |
|
inline |
Error code names.