You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
1.1 KiB
31 lines
1.1 KiB
#include <stdexcept>
|
|
|
|
#include <error.hh>
|
|
|
|
using namespace exopt::types;
|
|
|
|
namespace exopt {
|
|
Box<TracedError> Error::into_traced(std::stacktrace&& trace) &&noexcept {
|
|
struct DynamicTracedError final : TracedError {
|
|
_EO_CTORS_BASIC_DEFAULT(DynamicTracedError, _EO_NOTHING, noexcept);
|
|
virtual ~DynamicTracedError() noexcept = default;
|
|
|
|
DynamicTracedError(Error&& self, std::stacktrace&& trace) noexcept
|
|
: TracedError(std::move(trace), std::move(self.m_location))
|
|
, m_error(std::move(self)) {}
|
|
|
|
std::string_view message() const noexcept override { return m_error->message(); }
|
|
Option<Error const&> inner() const noexcept override { return Option<Error const&>(*m_error); }//{ return Option<Error const&>::from_pointer(std::as_const(m_error.get())); }
|
|
MaybeOwned<Report> into_report() && noexcept override { return std::move(*m_error).into_report(); }
|
|
MaybeOwned<Report> into_report() & noexcept override { return m_error->into_report(); }
|
|
|
|
|
|
private:
|
|
Box<Error> m_error;
|
|
};
|
|
#define ERR DynamicTracedError{std::move(*this), std::move(trace)}
|
|
return Box<TracedError>::template new_dynamic<DynamicTracedError, false>(ERR);
|
|
#undef ERR
|
|
}
|
|
}
|