88#include < system_error>
99#include < utility>
1010
11- #include " types.hpp"
1211#include " utils.hpp"
1312
1413namespace ystdlib ::error_handling {
@@ -23,43 +22,42 @@ namespace ystdlib::error_handling {
2322 * @see std::source_location::function_name()
2423 * @see std::source_location::line()
2524 */
26- template <ErrorCodeType ErrorType = std::error_code>
2725class TraceableException : public std ::exception {
2826public:
2927 // Constructors
3028 explicit TraceableException (
31- ErrorType error_code,
29+ std::error_code error_code,
3230 std::source_location const & where = std::source_location::current()
3331 )
34- : m_error_code{std::move ( error_code) },
32+ : m_error_code{error_code},
3533 m_where{where} {
3634 std::ostringstream oss;
3735 oss << where;
3836 m_what = oss.str ();
3937 }
4038
4139 explicit TraceableException (
42- ErrorType error_code,
40+ std::error_code error_code,
4341 std::string what,
4442 std::source_location const & where = std::source_location::current()
4543 )
46- : m_error_code{std::move ( error_code) },
44+ : m_error_code{error_code},
4745 m_what{std::move (what)},
4846 m_where{where} {}
4947
5048 // Methods implementing std::exception
5149 [[nodiscard]] auto what () const noexcept -> char const * override { return m_what.c_str (); }
5250
5351 // Methods
54- [[nodiscard]] auto error_code () const -> ErrorType { return m_error_code; }
52+ [[nodiscard]] auto error_code () const -> std::error_code { return m_error_code; }
5553
5654 [[nodiscard]] auto what () -> std::string& { return m_what; }
5755
5856 [[nodiscard]] auto where () const noexcept -> std::source_location const & { return m_where; }
5957
6058private:
6159 // Variables
62- ErrorType m_error_code;
60+ std::error_code m_error_code;
6361 std::string m_what;
6462 std::source_location m_where;
6563};
@@ -70,13 +68,8 @@ class TraceableException : public std::exception {
7068 */
7169// NOLINTBEGIN(bugprone-macro-parentheses, cppcoreguidelines-macro-usage)
7270#define YSTDLIB_ERROR_HANDLING_DEFINE_TRACEABLE_EXCEPTION (T ) \
73- class T : public ystdlib ::error_handling::TraceableException<> { \
74- using ystdlib::error_handling::TraceableException<>::TraceableException; \
75- }
76-
77- #define YSTDLIB_ERROR_HANDLING_DEFINE_TRACEABLE_EXCEPTION_WITH_ERROR_TYPE (T, E ) \
78- class T : public ystdlib ::error_handling::TraceableException<E> { \
79- using ystdlib::error_handling::TraceableException<E>::TraceableException; \
71+ class T : public ystdlib ::error_handling::TraceableException { \
72+ using ystdlib::error_handling::TraceableException::TraceableException; \
8073 }
8174// NOLINTEND(bugprone-macro-parentheses, cppcoreguidelines-macro-usage)
8275
0 commit comments