diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/libnix/expr.cc | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/libnix/expr.cc b/src/libnix/expr.cc index cead803425ba..9bbe80ab4c88 100644 --- a/src/libnix/expr.cc +++ b/src/libnix/expr.cc @@ -6,13 +6,21 @@ string printTerm(ATerm t) { char * s = ATwriteToString(t); + if (!s) throw Error("cannot print term"); return s; } Error badTerm(const format & f, ATerm t) { - return Error(format("%1%, in `%2%'") % f.str() % printTerm(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); } |