aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/error.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libutil/error.cc')
-rw-r--r--src/libutil/error.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/libutil/error.cc b/src/libutil/error.cc
index 0765a2945..59628d875 100644
--- a/src/libutil/error.cc
+++ b/src/libutil/error.cc
@@ -3,6 +3,7 @@
#include <iostream>
#include <optional>
#include "serialise.hh"
+#include <sstream>
namespace nix {
@@ -16,6 +17,21 @@ BaseError & BaseError::addPrefix(const FormatOrString & fs)
return *this;
}
+const string& BaseError::calcWhat() const
+{
+ if (what_.has_value())
+ return *what_;
+ else {
+ err.name = sname();
+
+ std::ostringstream oss;
+ oss << err;
+ what_ = oss.str();
+
+ return *what_;
+ }
+}
+
std::optional<string> ErrorInfo::programName = std::nullopt;
std::ostream& operator<<(std::ostream &os, const hintformat &hf)