Skip to content

Commit

Permalink
Gracefully handle forbidden in whois
Browse files Browse the repository at this point in the history
  • Loading branch information
nexy7574 committed Jun 26, 2024
1 parent 23f2252 commit 1f3f90b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/dendritecli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from rich.logging import RichHandler
from rich.prompt import Confirm, Prompt
from rich.table import Table
from httpx import HTTPStatusError

from . import api

Expand Down Expand Up @@ -258,7 +259,13 @@ def whois(http: api.HTTPAPIManager, user_id: str):
console.print("[red]Invalid user ID. user_id should be in the format @username:domain.tld.")
raise click.Abort
with console.status("Fetching user information..."):
_user = http.whois(user_id)
try:
_user = http.whois(user_id)
except HTTPStatusError as e:
if e.response.status_code == 401:
console.print("[red]Unauthorised. If you are looking up a remote user, you may not have permission.")
return
raise
console.print(_user)


Expand Down

0 comments on commit 1f3f90b

Please sign in to comment.