diff options
Diffstat (limited to 'src/libutil/error.cc')
-rw-r--r-- | src/libutil/error.cc | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/libutil/error.cc b/src/libutil/error.cc index b534ff87e..e5d6a9fa8 100644 --- a/src/libutil/error.cc +++ b/src/libutil/error.cc @@ -1,15 +1,15 @@ +#include "environment-variables.hh" #include "error.hh" +#include "logging.hh" #include "position.hh" +#include "terminal.hh" #include <iostream> #include <optional> -#include "serialise.hh" #include <sstream> namespace nix { -const std::string nativeSystem = SYSTEM; - void BaseError::addTrace(std::shared_ptr<Pos> && e, HintFmt hint) { err.traces.push_front(Trace { .pos = std::move(e), .hint = hint }); @@ -415,4 +415,17 @@ std::ostream & showErrorInfo(std::ostream & out, const ErrorInfo & einfo, bool s return out; } +void ignoreException(Verbosity lvl) +{ + /* Make sure no exceptions leave this function. + printError() also throws when remote is closed. */ + try { + try { + throw; + } catch (std::exception & e) { + printMsg(lvl, "error (ignored): %1%", e.what()); + } + } catch (...) { } +} + } |