diff options
author | Ben Burdette <bburdette@gmail.com> | 2020-03-24 09:18:23 -0600 |
---|---|---|
committer | Ben Burdette <bburdette@gmail.com> | 2020-03-24 09:18:23 -0600 |
commit | 4171ab4bbd95e9bb4b9d6c6e8c143002d92b0c06 (patch) | |
tree | 129c987255172357e8afb379e14b66f34542dd18 /src/libutil/error.hh | |
parent | aadd59d005bdabbb801f622dc1a0e3b12a5e5286 (diff) |
renaming
Diffstat (limited to 'src/libutil/error.hh')
-rw-r--r-- | src/libutil/error.hh | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/src/libutil/error.hh b/src/libutil/error.hh index 8dac1508e..69776eb8c 100644 --- a/src/libutil/error.hh +++ b/src/libutil/error.hh @@ -39,13 +39,40 @@ class NixCode { class ErrorInfo { public: ErrLevel level; - string errName; + string name; string description; - string toolName; + string program; optional<NixCode> nixCode; string hint; + ErrorInfo& GetEI() { return *this; } }; +template <class T> +class AddName : private T +{ + public: + T& name(const std::string &name){ + GetEI().name = name; + return *this; + } + protected: + ErrorInfo& GetEI() { return T::GetEI(); } +}; + +template <class T> +class AddDescription : private T +{ + public: + T& description(const std::string &description){ + GetEI().description = description; + return *this; + } + protected: + ErrorInfo& GetEI() { return T::GetEI(); } +}; + +typedef AddName<AddDescription<ErrorInfo>> StandardError; + string showErrLine(ErrLine &errLine); void print_code_lines(string &prefix, NixCode &nix_code); |