Skip to content

Commit eba6c01

Browse files
authored
fix: better error message if bad URL (#272)
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
1 parent 543e024 commit eba6c01

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/repo_review/__main__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import os
77
import sys
88
import typing
9+
import urllib.error
910
from collections.abc import Mapping, Sequence
1011
from pathlib import Path
1112
from typing import Any, Literal
@@ -17,6 +18,7 @@
1718
else:
1819
import rich_click as click
1920

21+
import rich
2022
import rich.console
2123
import rich.markdown
2224
import rich.syntax
@@ -265,7 +267,12 @@ def _remote_path_processor(package: Path) -> Path | GHPath:
265267
msg = "online repo must be of the form 'gh:org/repo@branch[:path]' (:branch missing)"
266268
raise click.BadParameter(msg)
267269
org_repo, branch = org_repo_branch.split("@", maxsplit=1)
268-
return GHPath(repo=org_repo, branch=branch, path=p[0] if p else "")
270+
try:
271+
return GHPath(repo=org_repo, branch=branch, path=p[0] if p else "")
272+
except urllib.error.HTTPError as e:
273+
rich.print(f"[red][bold]Error[/bold] accessing {e.url}", file=sys.stderr)
274+
rich.print(f"[red]{e}", file=sys.stderr)
275+
raise SystemExit(1) from None
269276

270277

271278
@click.command(context_settings={"help_option_names": ["-h", "--help"]})

0 commit comments

Comments
 (0)