aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Burdette <bburdette@gmail.com>2020-05-04 16:19:57 -0600
committerBen Burdette <bburdette@gmail.com>2020-05-04 16:19:57 -0600
commit7ffb5efdbc943851d2ee9d0573dca3e96b9bd742 (patch)
tree26a2aeeb28b86b95917a01278fed9b14faefe69d
parentf30de61578edd9c19744256985185045e7baab84 (diff)
appending to hints; remove _printError
-rw-r--r--src/error-demo/error-demo.cc7
-rw-r--r--src/libstore/build.cc12
-rw-r--r--src/libutil/logging.hh1
-rw-r--r--src/nix-daemon/nix-daemon.cc7
4 files changed, 18 insertions, 9 deletions
diff --git a/src/error-demo/error-demo.cc b/src/error-demo/error-demo.cc
index 514258416..82b03d71b 100644
--- a/src/error-demo/error-demo.cc
+++ b/src/error-demo/error-demo.cc
@@ -26,10 +26,13 @@ int main()
// ErrorInfo constructor
try {
- auto e = Error("generic error");
+ auto e = Error("some error");
throw DemoError(e.info());
} catch (Error &e) {
- logger->logEI(e.info());
+ ErrorInfo ei = e.info();
+ string prevhint = (e.info().hint.has_value() ? e.info().hint->str() : "");
+ ei.hint = std::optional(hintfmt("previous hint was: %s", normaltxt(prevhint)));
+ logger->logEI(ei);
}
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index bacbd5808..f8cc1ce36 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -488,14 +488,18 @@ void handleDiffHook(
auto diffRes = runProgram(diffHookOptions);
if (!statusOk(diffRes.first))
- throw ExecError(diffRes.first, "diff-hook program '%1%' %2%", diffHook, statusToString(diffRes.first));
+ throw ExecError(diffRes.first,
+ "diff-hook program '%1%' %2%",
+ diffHook,
+ statusToString(diffRes.first));
if (diffRes.second != "")
printError(chomp(diffRes.second));
} catch (Error & error) {
- // logError(error.info())
- // TODO append message onto errorinfo...
- _printError("diff hook execution failed: %s", error.what());
+ ErrorInfo ei = error.info();
+ string prevhint = (error.info().hint.has_value() ? error.info().hint->str() : "");
+ ei.hint = std::optional(hintfmt("diff hook execution failed: %s", prevhint));
+ logError(ei);
}
}
}
diff --git a/src/libutil/logging.hh b/src/libutil/logging.hh
index 5f03cdf41..0c4980b83 100644
--- a/src/libutil/logging.hh
+++ b/src/libutil/logging.hh
@@ -149,7 +149,6 @@ extern Verbosity verbosity; /* suppress msgs > this */
} \
} while (0)
-#define _printError(args...) printMsg(lvlError, args)
#define printError(args...) printMsg(lvlError, args)
#define printInfo(args...) printMsg(lvlInfo, args)
#define printTalkative(args...) printMsg(lvlTalkative, args)
diff --git a/src/nix-daemon/nix-daemon.cc b/src/nix-daemon/nix-daemon.cc
index 3cd2c3a6b..5336db136 100644
--- a/src/nix-daemon/nix-daemon.cc
+++ b/src/nix-daemon/nix-daemon.cc
@@ -246,9 +246,12 @@ static void daemonLoop(char * * argv)
} catch (Interrupted & e) {
return;
- } catch (Error & e) {
+ } catch (Error & error) {
// TODO append error message
- _printError("error processing connection: %1%", e.msg());
+ ErrorInfo ei = error.info();
+ string prevhint = (error.info().hint.has_value() ? error.info().hint->str() : "");
+ ei.hint = std::optional(hintfmt("error processing connection: %1%", prevhint));
+ logError(ei);
}
}
}