aboutsummaryrefslogtreecommitdiff
path: root/src/libutil
diff options
context:
space:
mode:
authorBen Burdette <bburdette@gmail.com>2020-06-27 12:19:31 -0600
committerBen Burdette <bburdette@gmail.com>2020-06-27 12:19:31 -0600
commitef24a0835d16baf1aa3f19ffa7ba7af54e6e63e6 (patch)
treeaa1d11c056ead9f41f46c13f163c7bcd9b7ab181 /src/libutil
parentbc9e87412cb94f74d2515a00a591a7b5e33c90d7 (diff)
showtrace as function arg
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/error.cc7
-rw-r--r--src/libutil/error.hh5
2 files changed, 7 insertions, 5 deletions
diff --git a/src/libutil/error.cc b/src/libutil/error.cc
index 49190eae1..0210555c5 100644
--- a/src/libutil/error.cc
+++ b/src/libutil/error.cc
@@ -34,7 +34,7 @@ const string& BaseError::calcWhat() const
}
std::optional<string> ErrorInfo::programName = std::nullopt;
-bool ErrorInfo::showTrace = false;
+// bool ErrorInfo::showTrace = false;
std::ostream& operator<<(std::ostream &os, const hintformat &hf)
{
@@ -211,7 +211,8 @@ void printAtPos(const string &prefix, const ErrPos &pos, std::ostream &out)
}
}
-std::ostream& operator<<(std::ostream &out, const ErrorInfo &einfo)
+// std::ostream& operator<<(std::ostream &out, const ErrorInfo &einfo)
+std::ostream& showErrorInfo(std::ostream &out, const ErrorInfo &einfo, bool showTrace)
{
auto errwidth = std::max<size_t>(getWindowSize().second, 20);
string prefix = "";
@@ -326,7 +327,7 @@ std::ostream& operator<<(std::ostream &out, const ErrorInfo &einfo)
}
// traces
- if (ErrorInfo::showTrace) {
+ if (showTrace) {
for (auto iter = einfo.traces.rbegin(); iter != einfo.traces.rend(); ++iter)
{
try {
diff --git a/src/libutil/error.hh b/src/libutil/error.hh
index dcde28453..a9da72b54 100644
--- a/src/libutil/error.hh
+++ b/src/libutil/error.hh
@@ -107,10 +107,11 @@ struct ErrorInfo {
std::list<Trace> traces;
static std::optional<string> programName;
- static bool showTrace;
+ // static bool showTrace;
};
-std::ostream& operator<<(std::ostream &out, const ErrorInfo &einfo);
+// std::ostream& operator<<(std::ostream &out, const ErrorInfo &einfo);
+std::ostream& showErrorInfo(std::ostream &out, const ErrorInfo &einfo, bool showTrace);
/* BaseError should generally not be caught, as it has Interrupted as
a subclass. Catch Error instead. */