about summary refs log tree commit diff
path: root/src/libmain/shared.cc
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-08-20T14·01+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-08-20T14·50+0200
commit373fad75e19a2f24db512621b8cedb627d03d49d (patch)
tree640fd0cac2ccc58f2db5a3f39eba6d0d67badb22 /src/libmain/shared.cc
parent392430b2c4ceb2e476abe2b3acc928581b2a1445 (diff)
Add some color
Diffstat (limited to 'src/libmain/shared.cc')
-rw-r--r--src/libmain/shared.cc11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc
index ba75847fdb63..73087524369f 100644
--- a/src/libmain/shared.cc
+++ b/src/libmain/shared.cc
@@ -247,6 +247,7 @@ void showManPage(const string & name)
 
 int handleExceptions(const string & programName, std::function<void()> fun)
 {
+    string error = ANSI_RED "error:" ANSI_NORMAL " ";
     try {
         try {
             fun();
@@ -263,21 +264,19 @@ int handleExceptions(const string & programName, std::function<void()> fun)
         return e.status;
     } catch (UsageError & e) {
         printMsg(lvlError,
-            format(
-                "error: %1%\n"
-                "Try `%2% --help' for more information.")
+            format(error + " %1%\nTry `%2% --help' for more information.")
             % e.what() % programName);
         return 1;
     } catch (BaseError & e) {
-        printMsg(lvlError, format("error: %1%%2%") % (settings.showTrace ? e.prefix() : "") % e.msg());
+        printMsg(lvlError, format(error + "%1%%2%") % (settings.showTrace ? e.prefix() : "") % e.msg());
         if (e.prefix() != "" && !settings.showTrace)
             printMsg(lvlError, "(use `--show-trace' to show detailed location information)");
         return e.status;
     } catch (std::bad_alloc & e) {
-        printMsg(lvlError, "error: out of memory");
+        printMsg(lvlError, error + "out of memory");
         return 1;
     } catch (std::exception & e) {
-        printMsg(lvlError, format("error: %1%") % e.what());
+        printMsg(lvlError, error + e.what());
         return 1;
     }