ruff: Fix TRY401 Redundant exception object included in logging.exception call.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2023-10-28 16:27:48 -07:00
parent 6b2861c3ec
commit 235f92afb0
6 changed files with 11 additions and 11 deletions

View file

@ -70,8 +70,8 @@ at syntax by: @mention-botname help"
return (
f"[Datapoint]({datapoint_link}) created."
) # Handles the case of successful datapoint creation
except ConnectionError as e:
logging.exception(str(e))
except ConnectionError:
logging.exception("Error connecting to Beeminder")
return "Uh-Oh, couldn't process the request \
right now.\nPlease try again later"
@ -92,8 +92,8 @@ class BeeminderHandler:
)
if r.status_code == 401:
bot_handler.quit("Invalid key!")
except ConnectionError as e:
logging.exception(str(e))
except ConnectionError:
logging.exception("Error connecting to Beeminder")
def usage(self) -> str:
return "This plugin allows users to add datapoints towards their Beeminder goals"

View file

@ -35,7 +35,7 @@ def get_bot_result(message_content: str, config: Dict[str, str], sender_id: str)
return "Error. No result."
return res_json["result"]["fulfillment"]["speech"]
except Exception as e:
logging.exception(str(e))
logging.exception("Error getting Dialogflow bot response")
return f"Error. {e}."

View file

@ -30,8 +30,8 @@ def make_flock_request(url: str, params: Dict[str, str]) -> Tuple[Any, str]:
try:
res = requests.get(url, params=params)
return (res.json(), None)
except ConnectionError as e:
logging.exception(str(e))
except ConnectionError:
logging.exception("Error connecting to Flock")
error = "Uh-Oh, couldn't process the request \
right now.\nPlease try again later"
return (None, error)

View file

@ -57,8 +57,8 @@ class GithubHandler:
r = requests.get(
self.GITHUB_ISSUE_URL_TEMPLATE.format(owner=owner, repo=repo, id=number)
)
except requests.exceptions.RequestException as e:
logging.exception(str(e))
except requests.exceptions.RequestException:
logging.exception("Error connecting to GitHub")
return None
if r.status_code != requests.codes.ok:
return None

View file

@ -62,7 +62,7 @@ def get_google_result(search_keywords: str) -> str:
return "Found no results."
return "Found Result: [{}]({})".format(results[0]["name"], results[0]["url"])
except Exception as e:
logging.exception(str(e))
logging.exception("Error fetching Google results")
return f"Error: Search failed. {e}."

View file

@ -296,7 +296,7 @@ class GameAdapter:
else:
self.send_reply(message, self.help_message())
except Exception as e:
logging.exception(str(e))
logging.exception("Error handling game message")
self.bot_handler.send_reply(message, f"Error {e}.")
def is_user_in_game(self, user_email: str) -> str: