Skip to content

Commit

Permalink
🥅 raise_for_status rather than raise ValueError for bad status codes
Browse files Browse the repository at this point in the history
  • Loading branch information
rchan26 committed Jan 3, 2024
1 parent cc9aae2 commit a0d3000
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions reginald/slack_bot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,7 @@ async def _process_request(
logging.info(f"Received unexpected event of type '{event['type']}'.")
return

if model_response.status_code != 200:
raise ValueError("Unable to get response.")
model_response.raise_for_status()
model_response = model_response.json()
except requests.exceptions.ConnectTimeout:
# if the model api times out, return a out of office message
Expand All @@ -445,7 +444,7 @@ async def _process_request(

# add a reply as required
if model_response and model_response["message"]:
logging.info(f"Posting reply {model_response['message']}.")
logging.info(f"Posting reply: {model_response['message']}.")
if model_response.get("error"):
if model_response["timeout"]:
# react with a sleeping emoji if timeout
Expand Down

0 comments on commit a0d3000

Please sign in to comment.