aboutsummaryrefslogtreecommitdiff
path: root/src/nix/prefetch.cc
diff options
context:
space:
mode:
authorGuillaume Maudoux <guillaume.maudoux@tweag.io>2022-04-29 00:12:25 +0200
committerGuillaume Maudoux <guillaume.maudoux@tweag.io>2022-04-29 00:12:25 +0200
commite93b59fbc5ada40e77d6f2b2a8bbd8e482418d6a (patch)
treef9436753bba299d648a6721845a9465b34a50062 /src/nix/prefetch.cc
parentf6baa4d18845297f3f7fc2434b7ade93a45718e7 (diff)
parent35393dc2c65765acb6cc99d6a976eab62c28a51d (diff)
Merge remote-tracking branch 'origin/master' into coerce-string
Diffstat (limited to 'src/nix/prefetch.cc')
-rw-r--r--src/nix/prefetch.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/nix/prefetch.cc b/src/nix/prefetch.cc
index 782149575..fc3823406 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, "while evaluating the source attribute to prefetch");
/* Extract the URL. */
- auto & attr = v.attrs->need(state->symbols.create("urls"));
- state->forceList(*attr.value, noPos, "while evaluating the urls to prefetch");
- 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, "while evaluating the urls to prefetch");
+ if (attr->value->listSize() < 1)
throw Error("'urls' list is empty");
- url = state->forceString(*attr.value->listElems()[0], noPos, "while evaluating the first url from the urls list");
+ url = state->forceString(*attr->value->listElems()[0], noPos, "while evaluating the first url from the urls list");
/* Extract the hash mode. */
auto attr2 = v.attrs->get(state->symbols.create("outputHashMode"));