Skip to content

Commit a2ddac7

Browse files
committed
ruff: Fix TRY002 Create your own exception.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
1 parent 751b471 commit a2ddac7

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

zulip/integrations/zephyr/zephyr_mirror_backend.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def to_zephyr_username(zulip_username: str) -> str:
7373
return user.lower() + "@ATHENA.MIT.EDU"
7474
match_user = re.match(r"([a-zA-Z0-9_]+)\|(.+)", user)
7575
if not match_user:
76-
raise Exception(f"Could not parse Zephyr realm for cross-realm user {zulip_username}")
76+
raise ValueError(f"Could not parse Zephyr realm for cross-realm user {zulip_username}")
7777
return match_user.group(1).lower() + "@" + match_user.group(2).upper()
7878

7979

@@ -307,7 +307,7 @@ def maybe_restart_mirroring_script() -> None:
307307
except Exception:
308308
logger.exception("Error restarting mirroring script; trying again... Traceback:")
309309
backoff.fail()
310-
raise Exception("Failed to reload too many times, aborting!")
310+
raise RuntimeError("Failed to reload too many times, aborting!")
311311

312312

313313
def process_loop(zulip_queue: "Queue[ZephyrDict]", log: Optional[IO[str]]) -> NoReturn:

zulip_bots/zulip_bots/bots/xkcd/xkcd.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def fetch_xkcd_query(mode: int, comic_id: Optional[str] = None) -> Dict[str, str
114114

115115
elif mode == XkcdBotCommand.COMIC_ID: # Fetch specific comic strip by id number.
116116
if comic_id is None:
117-
raise Exception("Missing comic_id argument")
117+
raise TypeError("Missing comic_id argument")
118118
url = XKCD_TEMPLATE_URL % (comic_id,)
119119

120120
fetched = requests.get(url)

zulip_bots/zulip_bots/test_lib.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ def unique_response(self) -> Dict[str, Any]:
6868

6969
def ensure_unique_response(self, responses: List[Dict[str, Any]]) -> None:
7070
if not responses:
71-
raise Exception("The bot is not responding for some reason.")
71+
raise ValueError("The bot is not responding for some reason.")
7272
if len(responses) > 1:
73-
raise Exception("The bot is giving too many responses for some reason.")
73+
raise ValueError("The bot is giving too many responses for some reason.")
7474

7575

7676
class DefaultTests:

0 commit comments

Comments
 (0)