diff options
author | Ben Burdette <bburdette@gmail.com> | 2020-05-07 16:43:36 -0600 |
---|---|---|
committer | Ben Burdette <bburdette@gmail.com> | 2020-05-07 16:43:36 -0600 |
commit | 1b801cec407454b904466153dfc56cec6b433f4b (patch) | |
tree | 3a7439d05a0d92feaa2fa307a9485dbf4ce69e6a /src/libutil | |
parent | e3901638b50d91ddc9c356adc35ded00a00fe94b (diff) |
pretending to be const
Diffstat (limited to 'src/libutil')
-rw-r--r-- | src/libutil/error.hh | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/libutil/error.hh b/src/libutil/error.hh index 2155ad344..19a806cc1 100644 --- a/src/libutil/error.hh +++ b/src/libutil/error.hh @@ -82,10 +82,10 @@ class BaseError : public std::exception { protected: string prefix_; // used for location traces etc. - ErrorInfo err; + mutable ErrorInfo err; - std::optional<string> what_; - const string& calcWhat() + mutable std::optional<string> what_; + const string& calcWhat() const { if (what_.has_value()) return *what_; @@ -131,12 +131,12 @@ public: #ifdef EXCEPTION_NEEDS_THROW_SPEC ~BaseError() throw () { }; - const char * what() throw () { return calcWhat().c_str(); } + const char * what() const throw () { return calcWhat().c_str(); } #else - const char * what() noexcept { return calcWhat().c_str(); } + const char * what() const noexcept override { return calcWhat().c_str(); } #endif - const string & msg() { return calcWhat(); } + const string & msg() const { return calcWhat(); } const string & prefix() const { return prefix_; } BaseError & addPrefix(const FormatOrString & fs); |