about summary refs log tree commit diff
path: root/src/libexpr/eval-inline.hh
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-04-04T17·05+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-04-04T17·05+0200
commit96b695ccab4a4c8c4ef7f14ac261df43dcc00743 (patch)
tree3511cba77ca830dbe598ed207b79ce21afc74870 /src/libexpr/eval-inline.hh
parentb62d36963c45ccaebb328fceaf0bb40f9c02a14b (diff)
forceList: Show position info
Diffstat (limited to 'src/libexpr/eval-inline.hh')
-rw-r--r--src/libexpr/eval-inline.hh15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/libexpr/eval-inline.hh b/src/libexpr/eval-inline.hh
index ffe8fa59cda0..c34e24d3da39 100644
--- a/src/libexpr/eval-inline.hh
+++ b/src/libexpr/eval-inline.hh
@@ -18,6 +18,12 @@ LocalNoInlineNoReturn(void throwTypeError(const char * s, const Value & v))
 }
 
 
+LocalNoInlineNoReturn(void throwTypeError(const char * s, const Value & v, const Pos & pos))
+{
+    throw TypeError(format(s) % showType(v) % pos);
+}
+
+
 void EvalState::forceValue(Value & v)
 {
     if (v.type == tThunk) {
@@ -56,4 +62,13 @@ inline void EvalState::forceList(Value & v)
         throwTypeError("value is %1% while a list was expected", v);
 }
 
+
+inline void EvalState::forceList(Value & v, const Pos & pos)
+{
+    forceValue(v);
+    if (v.type != tList)
+        throwTypeError("value is %1% while a list was expected, at %2%", v, pos);
+}
+
+
 }