about summary refs log tree commit diff
path: root/src/libutil/aterm.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libutil/aterm.cc')
-rw-r--r--src/libutil/aterm.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/libutil/aterm.cc b/src/libutil/aterm.cc
index de7c359521a7..dc6abf9e70e8 100644
--- a/src/libutil/aterm.cc
+++ b/src/libutil/aterm.cc
@@ -91,3 +91,16 @@ ATMatcher & operator >> (ATMatcher & pos, ATermList & out)
     out = (ATermList) t;
     return pos;
 }
+
+
+Error badTerm(const format & f, ATerm t)
+{
+    char * s = ATwriteToString(t);
+    if (!s) throw Error("cannot print term");
+    if (strlen(s) > 1000) {
+        int len;
+        s = ATwriteToSharedString(t, &len);
+        if (!s) throw Error("cannot print term");
+    }
+    return Error(format("%1%, in `%2%'") % f.str() % (string) s);
+}