about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2013-09-09T09·34+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2013-09-09T09·37+0200
commit8e765b8876ff67879a6bd1a067bad526b14a4045 (patch)
tree86c8644351e22611dc8bcbec9ab4ad2c8ac166d8
parente587aec1235d7834d04d6d9f7997bc010ef99925 (diff)
printValue: Show assertion errors inline
-rw-r--r--nix-repl.cc24
1 files changed, 18 insertions, 6 deletions
diff --git a/nix-repl.cc b/nix-repl.cc
index a6e5f78ec9ce..f7eb6ab5c0d7 100644
--- a/nix-repl.cc
+++ b/nix-repl.cc
@@ -390,13 +390,20 @@ std::ostream & NixRepl::printValue(std::ostream & str, Value & v, unsigned int m
                 }
             }
 
-            foreach (Sorted::iterator, i, sorted)
+            foreach (Sorted::iterator, i, sorted) {
+                str << i->first << " = ";
                 if (hidden.find(i->first) != hidden.end())
-                    str << i->first << " = «...»; ";
+                    str << "«...»";
                 else if (seen.find(i->second) != seen.end())
-                    str << i->first << " = «repeated»; ";
+                    str << "«repeated»";
                 else
-                    printValue(str << i->first << " = ", *i->second, maxDepth - 1, seen) << "; ";
+                    try {
+                        printValue(str, *i->second, maxDepth - 1, seen);
+                    } catch (AssertionError & e) {
+                        str << "«error: " << e.msg() << "»";
+                    }
+                str << "; ";
+            }
 
         } else
             str << "... ";
@@ -413,9 +420,14 @@ std::ostream & NixRepl::printValue(std::ostream & str, Value & v, unsigned int m
         if (maxDepth > 0)
             for (unsigned int n = 0; n < v.list.length; ++n) {
                 if (seen.find(v.list.elems[n]) != seen.end())
-                    str << "«repeated» ";
+                    str << "«repeated»";
                 else
-                    printValue(str, *v.list.elems[n], maxDepth - 1, seen) << " ";
+                    try {
+                        printValue(str, *v.list.elems[n], maxDepth - 1, seen);
+                    } catch (AssertionError & e) {
+                        str << "«error: " << e.msg() << "»";
+                    }
+                str << " ";
             }
         else
             str << "... ";