aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/error.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/libutil/error.hh')
-rw-r--r--src/libutil/error.hh16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/libutil/error.hh b/src/libutil/error.hh
index c3bb8c0df..7d236028c 100644
--- a/src/libutil/error.hh
+++ b/src/libutil/error.hh
@@ -86,6 +86,7 @@ void printCodeLines(std::ostream & out,
struct Trace {
std::shared_ptr<AbstractPos> pos;
hintformat hint;
+ bool frame;
};
struct ErrorInfo {
@@ -114,6 +115,8 @@ protected:
public:
unsigned int status = 1; // exit status
+ BaseError(const BaseError &) = default;
+
template<typename... Args>
BaseError(unsigned int status, const Args & ... args)
: err { .level = lvlError, .msg = hintfmt(args...) }
@@ -152,15 +155,22 @@ public:
const std::string & msg() const { return calcWhat(); }
const ErrorInfo & info() const { calcWhat(); return err; }
+ void pushTrace(Trace trace)
+ {
+ err.traces.push_front(trace);
+ }
+
template<typename... Args>
- void addTrace(std::shared_ptr<AbstractPos> && e, const std::string & fs, const Args & ... args)
+ void addTrace(std::shared_ptr<AbstractPos> && e, std::string_view fs, const Args & ... args)
{
- addTrace(std::move(e), hintfmt(fs, args...));
+ addTrace(std::move(e), hintfmt(std::string(fs), args...));
}
- void addTrace(std::shared_ptr<AbstractPos> && e, hintformat hint);
+ void addTrace(std::shared_ptr<AbstractPos> && e, hintformat hint, bool frame = false);
bool hasTrace() const { return !err.traces.empty(); }
+
+ const ErrorInfo & info() { return err; };
};
#define MakeError(newClass, superClass) \