Skip to content

Commit 235f92a

Browse files
committed
ruff: Fix TRY401 Redundant exception object included in logging.exception call.
Signed-off-by: Anders Kaseorg <[email protected]>
1 parent 6b2861c commit 235f92a

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

zulip_bots/zulip_bots/bots/beeminder/beeminder.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ def get_beeminder_response(message_content: str, config_info: Dict[str, str]) ->
7070
return (
7171
f"[Datapoint]({datapoint_link}) created."
7272
) # Handles the case of successful datapoint creation
73-
except ConnectionError as e:
74-
logging.exception(str(e))
73+
except ConnectionError:
74+
logging.exception("Error connecting to Beeminder")
7575
return "Uh-Oh, couldn't process the request \
7676
right now.\nPlease try again later"
7777

@@ -92,8 +92,8 @@ def initialize(self, bot_handler: BotHandler) -> None:
9292
)
9393
if r.status_code == 401:
9494
bot_handler.quit("Invalid key!")
95-
except ConnectionError as e:
96-
logging.exception(str(e))
95+
except ConnectionError:
96+
logging.exception("Error connecting to Beeminder")
9797

9898
def usage(self) -> str:
9999
return "This plugin allows users to add datapoints towards their Beeminder goals"

zulip_bots/zulip_bots/bots/dialogflow/dialogflow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def get_bot_result(message_content: str, config: Dict[str, str], sender_id: str)
3535
return "Error. No result."
3636
return res_json["result"]["fulfillment"]["speech"]
3737
except Exception as e:
38-
logging.exception(str(e))
38+
logging.exception("Error getting Dialogflow bot response")
3939
return f"Error. {e}."
4040

4141

zulip_bots/zulip_bots/bots/flock/flock.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ def make_flock_request(url: str, params: Dict[str, str]) -> Tuple[Any, str]:
3030
try:
3131
res = requests.get(url, params=params)
3232
return (res.json(), None)
33-
except ConnectionError as e:
34-
logging.exception(str(e))
33+
except ConnectionError:
34+
logging.exception("Error connecting to Flock")
3535
error = "Uh-Oh, couldn't process the request \
3636
right now.\nPlease try again later"
3737
return (None, error)

zulip_bots/zulip_bots/bots/github_detail/github_detail.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ def get_details_from_github(
5757
r = requests.get(
5858
self.GITHUB_ISSUE_URL_TEMPLATE.format(owner=owner, repo=repo, id=number)
5959
)
60-
except requests.exceptions.RequestException as e:
61-
logging.exception(str(e))
60+
except requests.exceptions.RequestException:
61+
logging.exception("Error connecting to GitHub")
6262
return None
6363
if r.status_code != requests.codes.ok:
6464
return None

zulip_bots/zulip_bots/bots/google_search/google_search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def get_google_result(search_keywords: str) -> str:
6262
return "Found no results."
6363
return "Found Result: [{}]({})".format(results[0]["name"], results[0]["url"])
6464
except Exception as e:
65-
logging.exception(str(e))
65+
logging.exception("Error fetching Google results")
6666
return f"Error: Search failed. {e}."
6767

6868

zulip_bots/zulip_bots/game_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ def handle_message(self, message: Dict[str, Any], bot_handler: BotHandler) -> No
296296
else:
297297
self.send_reply(message, self.help_message())
298298
except Exception as e:
299-
logging.exception(str(e))
299+
logging.exception("Error handling game message")
300300
self.bot_handler.send_reply(message, f"Error {e}.")
301301

302302
def is_user_in_game(self, user_email: str) -> str:

0 commit comments

Comments
 (0)