aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libexpr/attr-set.hh12
-rw-r--r--src/nix/bundle.cc6
-rw-r--r--src/nix/prefetch.cc10
3 files changed, 10 insertions, 18 deletions
diff --git a/src/libexpr/attr-set.hh b/src/libexpr/attr-set.hh
index cad9743ea..1e6c548c6 100644
--- a/src/libexpr/attr-set.hh
+++ b/src/libexpr/attr-set.hh
@@ -73,18 +73,6 @@ public:
return nullptr;
}
- Attr & need(const Symbol & name, const Pos & pos = noPos)
- {
- auto a = get(name);
- if (!a)
- throw Error({
- .msg = hintfmt("attribute '%s' missing", name),
- .errPos = pos
- });
-
- return *a;
- }
-
iterator begin() { return &attrs[0]; }
iterator end() { return &attrs[size_]; }
diff --git a/src/nix/bundle.cc b/src/nix/bundle.cc
index 81fb8464a..ee91e8ed0 100644
--- a/src/nix/bundle.cc
+++ b/src/nix/bundle.cc
@@ -110,8 +110,10 @@ struct CmdBundle : InstallableCommand
auto outPathS = store->printStorePath(outPath);
if (!outLink) {
- auto &attr = vRes->attrs->need(evalState->sName);
- outLink = evalState->forceStringNoCtx(*attr.value,*attr.pos);
+ auto * attr = vRes->attrs->get(evalState->sName);
+ if (!attr)
+ throw Error("attribute 'name' missing");
+ outLink = evalState->forceStringNoCtx(*attr->value, *attr->pos);
}
// TODO: will crash if not a localFSStore?
diff --git a/src/nix/prefetch.cc b/src/nix/prefetch.cc
index f2dd44ba4..ce3288dc1 100644
--- a/src/nix/prefetch.cc
+++ b/src/nix/prefetch.cc
@@ -199,11 +199,13 @@ static int main_nix_prefetch_url(int argc, char * * argv)
state->forceAttrs(v, noPos);
/* Extract the URL. */
- auto & attr = v.attrs->need(state->symbols.create("urls"));
- state->forceList(*attr.value, noPos);
- if (attr.value->listSize() < 1)
+ auto * attr = v.attrs->get(state->symbols.create("urls"));
+ if (!attr)
+ throw Error("attribute 'urls' missing");
+ state->forceList(*attr->value, noPos);
+ if (attr->value->listSize() < 1)
throw Error("'urls' list is empty");
- url = state->forceString(*attr.value->listElems()[0]);
+ url = state->forceString(*attr->value->listElems()[0]);
/* Extract the hash mode. */
auto attr2 = v.attrs->get(state->symbols.create("outputHashMode"));