Skip to content

Commit

Permalink
Merge #145
Browse files Browse the repository at this point in the history
145: improve error message when no hash is found r=figsoda a=figsoda



Co-authored-by: figsoda <[email protected]>
  • Loading branch information
bors[bot] and figsoda authored Mar 27, 2023
2 parents 295cc39 + cb0edae commit f7eba58
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion nix_update/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import re
import shutil
import subprocess
import sys
import tempfile
import tomllib
from concurrent.futures import ThreadPoolExecutor
Expand Down Expand Up @@ -90,6 +91,7 @@ def nix_prefetch(opts: Options, attr: str) -> str:

extra_env: Dict[str, str] = {}
tempdir: Optional[tempfile.TemporaryDirectory[str]] = None
stderr = ""
if extra_env.get("XDG_RUNTIME_DIR") is None:
tempdir = tempfile.TemporaryDirectory()
extra_env["XDG_RUNTIME_DIR"] = tempdir.name
Expand Down Expand Up @@ -117,7 +119,10 @@ def nix_prefetch(opts: Options, attr: str) -> str:
tempdir.cleanup()

if got == "":
raise UpdateError(f"empty hash when trying to update {opts.attribute}.{attr}")
print(stderr, file=sys.stderr)
raise UpdateError(
f"failed to retrieve hash when trying to update {opts.attribute}.{attr}"
)
else:
return got

Expand Down

0 comments on commit f7eba58

Please sign in to comment.