Răsfoiți Sursa

output a slightly more helpful error message when we cannot download … (#5140)

* output a slightly more helpful error message when we cannot download bun installation script

* add raises
Khaleel Al-Adhami 3 săptămâni în urmă
părinte
comite
3bcf01d9fc
1 a modificat fișierele cu 10 adăugiri și 2 ștergeri
  1. 10 2
      reflex/utils/prerequisites.py

+ 10 - 2
reflex/utils/prerequisites.py

@@ -1134,12 +1134,20 @@ def download_and_run(url: str, *args, show_status: bool = False, **env):
         args: The arguments to pass to the script.
         show_status: Whether to show the status of the script.
         env: The environment variables to use.
+
+    Raises:
+        Exit: If the script fails to download.
     """
     # Download the script
     console.debug(f"Downloading {url}")
-    response = net.get(url)
-    if response.status_code != httpx.codes.OK:
+    try:
+        response = net.get(url)
         response.raise_for_status()
+    except httpx.HTTPError as e:
+        console.error(
+            f"Failed to download bun install script. You can install or update bun manually from https://bun.sh \n{e}"
+        )
+        raise typer.Exit(1) from None
 
     # Save the script to a temporary file.
     script = Path(tempfile.NamedTemporaryFile().name)