Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
Error.hpp
1#pragma once
2
3#include <fmt/format.h>
4#include <fmt/std.h>
5
6#include <string>
7#include <utility>
8
9// for the static_assert at the bottom which fixes clang compilation:
10// see: https://godbolt.org/z/fzTjMd7G1 vs https://godbolt.org/z/jhKG7deen
11#include <any>
12#include <expected>
13
14namespace util::async {
15
26 ExecutionError(std::string tid, std::string msg)
27 : message{fmt::format("Thread {} exit with exception: {}", std::move(tid), std::move(msg))}
28 {
29 }
30
31 ExecutionError(ExecutionError const&) = default;
32 ExecutionError(ExecutionError&&) = default;
34 operator=(ExecutionError&&) = default;
36 operator=(ExecutionError const&) = default;
37
43 [[nodiscard]]
44 operator char const*() const noexcept
45 {
46 return message.c_str();
47 }
48
49 std::string message;
50};
51
52// these are not the droids you are looking for...
53static_assert(std::is_copy_constructible_v<std::expected<std::any, ExecutionError>>);
54
55} // namespace util::async
This namespace implements an async framework built on top of execution contexts.
Definition AnyExecutionContext.hpp:17
Error channel type for async operation of any ExecutionContext.
Definition Error.hpp:19
ExecutionError(std::string tid, std::string msg)
Construct a new Execution Error object.
Definition Error.hpp:26