diff options
author | regnat <rg@regnat.ovh> | 2022-03-03 10:50:35 +0100 |
---|---|---|
committer | regnat <rg@regnat.ovh> | 2022-03-07 10:09:09 +0100 |
commit | c0792b1546ceed1c02a02ca1286ead55f79d5798 (patch) | |
tree | b03b57763994b13ea800eb1c88f96d2a2dcfae14 /src/libutil/error.hh | |
parent | b09baf690bb00125805a02e0feae9636b2114599 (diff) |
Implement a suggestions mechanism
Each `Error` class now includes a set of suggestions, and these are printed by
the top-level handler.
Diffstat (limited to 'src/libutil/error.hh')
-rw-r--r-- | src/libutil/error.hh | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/libutil/error.hh b/src/libutil/error.hh index d55e1d701..600e94888 100644 --- a/src/libutil/error.hh +++ b/src/libutil/error.hh @@ -1,5 +1,6 @@ #pragma once +#include "suggestions.hh" #include "ref.hh" #include "types.hh" #include "fmt.hh" @@ -112,6 +113,8 @@ struct ErrorInfo { std::optional<ErrPos> errPos; std::list<Trace> traces; + Suggestions suggestions; + static std::optional<std::string> programName; }; @@ -141,6 +144,11 @@ public: : err { .level = lvlError, .msg = hintfmt(fs, args...) } { } + template<typename... Args> + BaseError(const Suggestions & sug, const Args & ... args) + : err { .level = lvlError, .msg = hintfmt(args...), .suggestions = sug } + { } + BaseError(hintformat hint) : err { .level = lvlError, .msg = hint } { } |