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.hh24
1 files changed, 9 insertions, 15 deletions
diff --git a/src/libutil/error.hh b/src/libutil/error.hh
index f3babcbde..ff58d3e00 100644
--- a/src/libutil/error.hh
+++ b/src/libutil/error.hh
@@ -38,13 +38,14 @@ namespace nix {
ErrorInfo structs are sent to the logger as part of an exception, or directly with the
logError or logWarning macros.
- See the error-demo.cc program for usage examples.
+ See libutil/tests/logging.cc for usage examples.
*/
typedef enum {
lvlError = 0,
lvlWarn,
+ lvlNotice,
lvlInfo,
lvlTalkative,
lvlChatty,
@@ -106,9 +107,8 @@ struct Trace {
struct ErrorInfo {
Verbosity level;
- string name;
- string description;
- std::optional<hintformat> hint;
+ string name; // FIXME: rename
+ hintformat msg;
std::optional<ErrPos> errPos;
std::list<Trace> traces;
@@ -132,23 +132,17 @@ public:
template<typename... Args>
BaseError(unsigned int status, const Args & ... args)
- : err {.level = lvlError,
- .hint = hintfmt(args...)
- }
+ : err { .level = lvlError, .msg = hintfmt(args...) }
, status(status)
{ }
template<typename... Args>
BaseError(const std::string & fs, const Args & ... args)
- : err {.level = lvlError,
- .hint = hintfmt(fs, args...)
- }
+ : err { .level = lvlError, .msg = hintfmt(fs, args...) }
{ }
BaseError(hintformat hint)
- : err {.level = lvlError,
- .hint = hint
- }
+ : err { .level = lvlError, .msg = hint }
{ }
BaseError(ErrorInfo && e)
@@ -169,7 +163,7 @@ public:
#endif
const string & msg() const { return calcWhat(); }
- const ErrorInfo & info() { calcWhat(); return err; }
+ const ErrorInfo & info() const { calcWhat(); return err; }
template<typename... Args>
BaseError & addTrace(std::optional<ErrPos> e, const string &fs, const Args & ... args)
@@ -205,7 +199,7 @@ public:
{
errNo = errno;
auto hf = hintfmt(args...);
- err.hint = hintfmt("%1%: %2%", normaltxt(hf.str()), strerror(errNo));
+ err.msg = hintfmt("%1%: %2%", normaltxt(hf.str()), strerror(errNo));
}
virtual const char* sname() const override { return "SysError"; }