aboutsummaryrefslogtreecommitdiff
path: root/src/libmain/shared.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2009-06-30 13:28:29 +0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2009-06-30 13:28:29 +0000
commitf2c3fc519190b021f0bb3b66f58d0fe7fc40b0e7 (patch)
tree3f63dc0097d73ec82250a77574703e744eb03c81 /src/libmain/shared.cc
parenta2fc3a53ba87d3688dae0554bfdb2fe3fb3dbf2a (diff)
* 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.
Diffstat (limited to 'src/libmain/shared.cc')
-rw-r--r--src/libmain/shared.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc
index e080d8cc5..10ccb2985 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());