diff options
author | Fabian Schmitthenner <development@schmitthenner.eu> | 2016-03-19T13·52+0000 |
---|---|---|
committer | Fabian Schmitthenner <development@schmitthenner.eu> | 2016-03-19T13·55+0000 |
commit | 828cf7b0582220ce568b69e9cc51af794bdd2416 (patch) | |
tree | cc8adb5a8d97b19beaf8a6a61bfc29a944600b4b /nix-repl.cc | |
parent | e37bca136eb58cc156f88cc8aa8e7bf47ed31d42 (diff) |
show trace of errors when using --show-trace
Diffstat (limited to 'nix-repl.cc')
-rw-r--r-- | nix-repl.cc | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/nix-repl.cc b/nix-repl.cc index a9a21ae766d8..d1c67276c2f3 100644 --- a/nix-repl.cc +++ b/nix-repl.cc @@ -14,6 +14,7 @@ #include "get-drvs.hh" #include "derivations.hh" #include "affinity.hh" +#include "globals.hh" using namespace std; using namespace nix; @@ -108,6 +109,7 @@ NixRepl::NixRepl(const Strings & searchPath, nix::ref<Store> store) void NixRepl::mainLoop(const Strings & files) { + string error = ANSI_RED "error:" ANSI_NORMAL " "; std::cout << "Welcome to Nix version " << NIX_VERSION << ". Type :? for help." << std::endl << std::endl; for (auto & i : files) @@ -138,12 +140,12 @@ void NixRepl::mainLoop(const Strings & files) // input without clearing the input so far. continue; } else { - printMsg(lvlError, "error: " + e.msg()); + printMsg(lvlError, format(error + "%1%%2%") % (settings.showTrace ? e.prefix() : "") % e.msg()); } } catch (Error & e) { - printMsg(lvlError, "error: " + e.msg()); + printMsg(lvlError, format(error + "%1%%2%") % (settings.showTrace ? e.prefix() : "") % e.msg()); } catch (Interrupted & e) { - printMsg(lvlError, "error: " + e.msg()); + printMsg(lvlError, format(error + "%1%%2%") % (settings.showTrace ? e.prefix() : "") % e.msg()); } // We handled the current input fully, so we should clear it and read brand new input. |