rotor
Event loop friendly C++ actor micro-framework
 
Loading...
Searching...
No Matches
extended_error.h
1#pragma once
2
3//
4// Copyright (c) 2021-2024 Ivan Baidakou (basiliscos) (the dot dmol at gmail dot com)
5//
6// Distributed under the MIT Software License
7//
8
9#include "arc.hpp"
10#include "message.h"
11#include <string>
12#include <system_error>
13
14#if defined(_MSC_VER)
15#pragma warning(push)
16#pragma warning(disable : 4251)
17#endif
18
19namespace rotor {
20
21struct extended_error_t;
22struct message_stringifier_t;
23
26
37struct ROTOR_API extended_error_t : arc_base_t<extended_error_t> {
39 std::string context;
40
42 std::error_code ec;
43
46
49
51 extended_error_t(const std::string &context_, const std::error_code &ec_, const extended_error_ptr_t &next_ = {},
52 const message_ptr_t &request_ = {}) noexcept
53 : context{context_}, ec{ec_}, next{next_}, request{request_} {}
54
62 std::string message(const message_stringifier_t *stringifier = nullptr) const noexcept;
63
67 extended_error_ptr_t root() const noexcept;
68};
69
71ROTOR_API extended_error_ptr_t make_error(const std::string &context_, const std::error_code &ec_,
72 const extended_error_ptr_t &next_ = {},
73 const message_ptr_t &request_ = {}) noexcept;
74
75} // namespace rotor
76
77#if defined(_MSC_VER)
78#pragma warning(pop)
79#endif
Basic namespace for all rotor functionalities.
Definition rotor.hpp:21
intrusive_ptr_t< message_base_t > message_ptr_t
intrusive pointer for message
Definition message.h:118
intrusive_ptr_t< extended_error_t > extended_error_ptr_t
intrusive pointer to extended error type
Definition extended_error.h:25
boost::intrusive_ref_counter< T, counter_policy_t > arc_base_t
base class to inject ref-counter with the specified policy
Definition arc.hpp:24
boost::intrusive_ptr< T > intrusive_ptr_t
alias for intrusive pointer
Definition arc.hpp:27
Holds string context, error_code and the pointer to the following error.
Definition extended_error.h:37
extended_error_t(const std::string &context_, const std::error_code &ec_, const extended_error_ptr_t &next_={}, const message_ptr_t &request_={}) noexcept
extened error constructor
Definition extended_error.h:51
message_ptr_t request
pointer request caused error
Definition extended_error.h:48
std::string context
error context, usually actor identity
Definition extended_error.h:39
std::string message(const message_stringifier_t *stringifier=nullptr) const noexcept
human-readable detailed description of the error
extended_error_ptr_t next
pointer to the parent error
Definition extended_error.h:45
std::error_code ec
abstract error code, describing occurred error
Definition extended_error.h:42
Abstract interface for making textual/string representation of a message.
Definition message_stringifier.h:36