diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2003-11-18T11·22+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2003-11-18T11·22+0000 |
commit | ce92d1bf1434562f5b80320c503768c4d06f1f8d (patch) | |
tree | 477c80de94f3c403115f80bad450003946af2889 /src/libutil | |
parent | 9f0f020929c9e093405cc6193d2f227cab763912 (diff) |
* "Nix expression" -> "store expression".
* More refactoring.
Diffstat (limited to 'src/libutil')
-rw-r--r-- | src/libutil/aterm.cc | 13 | ||||
-rw-r--r-- | src/libutil/aterm.hh | 5 |
2 files changed, 18 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); +} diff --git a/src/libutil/aterm.hh b/src/libutil/aterm.hh index 16d8d6bb6dfd..d38d8e3f4d7a 100644 --- a/src/libutil/aterm.hh +++ b/src/libutil/aterm.hh @@ -74,4 +74,9 @@ ATMatcher & operator >> (ATMatcher & pos, const string & s); ATMatcher & operator >> (ATMatcher & pos, ATermList & out); +/* Throw an exception with an error message containing the given + aterm. */ +Error badTerm(const format & f, ATerm t); + + #endif /* !__ATERM_H */ |