From f2c3fc519190b021f0bb3b66f58d0fe7fc40b0e7 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 30 Jun 2009 13:28:29 +0000 Subject: * Don't show trace information by default (`--show-trace' to enable). NixOS evaluation errors in particular look intimidating and generally aren't very useful. Ideally the builtins.throw messages should be self-contained. --- src/libmain/shared.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/libmain/shared.cc') diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc index e080d8cc5a8a..10ccb2985f74 100644 --- a/src/libmain/shared.cc +++ b/src/libmain/shared.cc @@ -125,6 +125,9 @@ RemoveTempRoots::~RemoveTempRoots() } +static bool showTrace = false; + + /* Initialize and reorder arguments, then call the actual argument processor. */ static void initAndRun(int argc, char * * argv) @@ -243,6 +246,8 @@ static void initAndRun(int argc, char * * argv) maxSilentTime = getIntArg(arg, i, args.end()); else if (arg == "--no-build-hook") useBuildHook = false; + else if (arg == "--show-trace") + showTrace = true; else if (arg == "--option") { ++i; if (i == args.end()) throw UsageError("`--option' requires two arguments"); string name = *i; @@ -365,7 +370,9 @@ int main(int argc, char * * argv) % e.what() % programId); return 1; } catch (BaseError & e) { - printMsg(lvlError, format("error: %1%") % e.msg()); + printMsg(lvlError, format("error: %1%%2%") % (showTrace ? e.prefix() : "") % e.msg()); + if (e.prefix() != "" && !showTrace) + printMsg(lvlError, "(use `--show-trace' to show detailed location information)"); return 1; } catch (std::exception & e) { printMsg(lvlError, format("error: %1%") % e.what()); -- cgit 1.4.1