aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/eval-cache.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libexpr/eval-cache.cc')
-rw-r--r--src/libexpr/eval-cache.cc49
1 files changed, 41 insertions, 8 deletions
diff --git a/src/libexpr/eval-cache.cc b/src/libexpr/eval-cache.cc
index 0eb4bc79e..e9d9d02a4 100644
--- a/src/libexpr/eval-cache.cc
+++ b/src/libexpr/eval-cache.cc
@@ -554,14 +554,22 @@ std::string AttrCursor::getString()
debug("using cached string attribute '%s'", getAttrPathStr());
return s->first;
} else
- throw TypeError("'%s' is not a string", getAttrPathStr());
+ {
+ auto e = TypeError("'%s' is not a string", getAttrPathStr());
+ root->state.debugLastTrace(e);
+ throw e;
+ }
}
}
auto & v = forceValue();
if (v.type() != nString && v.type() != nPath)
- throw TypeError("'%s' is not a string but %s", getAttrPathStr(), showType(v.type()));
+ {
+ auto e = TypeError("'%s' is not a string but %s", getAttrPathStr(), showType(v.type()));
+ root->state.debugLastTrace(e);
+ throw e;
+ }
return v.type() == nString ? v.string.s : v.path;
}
@@ -585,7 +593,11 @@ string_t AttrCursor::getStringWithContext()
return *s;
}
} else
- throw TypeError("'%s' is not a string", getAttrPathStr());
+ {
+ auto e = TypeError("'%s' is not a string", getAttrPathStr());
+ root->state.debugLastTrace(e);
+ throw e;
+ }
}
}
@@ -596,7 +608,12 @@ string_t AttrCursor::getStringWithContext()
else if (v.type() == nPath)
return {v.path, {}};
else
- throw TypeError("'%s' is not a string but %s", getAttrPathStr(), showType(v.type()));
+ {
+ auto e = TypeError("'%s' is not a string but %s", getAttrPathStr(), showType(v.type()));
+ root->state.debugLastTrace(e);
+ throw e;
+ return {v.path, {}}; // should never execute
+ }
}
bool AttrCursor::getBool()
@@ -609,14 +626,22 @@ bool AttrCursor::getBool()
debug("using cached Boolean attribute '%s'", getAttrPathStr());
return *b;
} else
- throw TypeError("'%s' is not a Boolean", getAttrPathStr());
+ {
+ auto e = TypeError("'%s' is not a Boolean", getAttrPathStr());
+ root->state.debugLastTrace(e);
+ throw e;
+ }
}
}
auto & v = forceValue();
if (v.type() != nBool)
- throw TypeError("'%s' is not a Boolean", getAttrPathStr());
+ {
+ auto e = TypeError("'%s' is not a Boolean", getAttrPathStr());
+ root->state.debugLastTrace(e);
+ throw e;
+ }
return v.boolean;
}
@@ -664,14 +689,22 @@ std::vector<Symbol> AttrCursor::getAttrs()
debug("using cached attrset attribute '%s'", getAttrPathStr());
return *attrs;
} else
- throw TypeError("'%s' is not an attribute set", getAttrPathStr());
+ {
+ auto e = TypeError("'%s' is not an attribute set", getAttrPathStr());
+ root->state.debugLastTrace(e);
+ throw e;
+ }
}
}
auto & v = forceValue();
if (v.type() != nAttrs)
- throw TypeError("'%s' is not an attribute set", getAttrPathStr());
+ {
+ auto e = TypeError("'%s' is not an attribute set", getAttrPathStr());
+ root->state.debugLastTrace(e);
+ throw e;
+ }
std::vector<Symbol> attrs;
for (auto & attr : *getValue().attrs)