Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/general.py
diff options
context:
space:
mode:
authorAnton Hvornum <anton@hvornum.se>2022-08-10 11:02:24 +0200
committerGitHub <noreply@github.com>2022-08-10 11:02:24 +0200
commit242f8076bb7679a565433e30c61662c70f37b06f (patch)
treee5c766a94c923ce1d113f33aec47e6d92dc41e7c /archinstall/lib/general.py
parent6213560a0543b11eb007020b044255edaf009d4b (diff)
Adding better error output for when loading remote configurations goes wrong. (#1415)
Diffstat (limited to 'archinstall/lib/general.py')
-rw-r--r--archinstall/lib/general.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/archinstall/lib/general.py b/archinstall/lib/general.py
index 27f444e8..9edbaea8 100644
--- a/archinstall/lib/general.py
+++ b/archinstall/lib/general.py
@@ -12,6 +12,7 @@ import time
import re
import urllib.parse
import urllib.request
+import urllib.error
import pathlib
from datetime import datetime, date
from typing import Callable, Optional, Dict, Any, List, Union, Iterator, TYPE_CHECKING
@@ -548,8 +549,12 @@ def json_stream_to_structure(configuration_identifier : str, stream :str, target
parsed_url = urllib.parse.urlparse(stream)
if parsed_url.scheme: # The stream is in fact a URL that should be grabbed
- with urllib.request.urlopen(urllib.request.Request(stream, headers={'User-Agent': 'ArchInstall'})) as response:
- target.update(json.loads(response.read()))
+ try:
+ with urllib.request.urlopen(urllib.request.Request(stream, headers={'User-Agent': 'ArchInstall'})) as response:
+ target.update(json.loads(response.read()))
+ except urllib.error.HTTPError as error:
+ log(f"Could not load {configuration_identifier} via {parsed_url} due to: {error}", level=logging.ERROR, fg="red")
+ return False
else:
if pathlib.Path(stream).exists():
try: