Skip to content

Commit

Permalink
ruff: Fix TRY002 Create your own exception.
Browse files Browse the repository at this point in the history
Signed-off-by: Anders Kaseorg <[email protected]>
  • Loading branch information
andersk committed Nov 2, 2023
1 parent 751b471 commit a2ddac7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions zulip/integrations/zephyr/zephyr_mirror_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def to_zephyr_username(zulip_username: str) -> str:
return user.lower() + "@ATHENA.MIT.EDU"
match_user = re.match(r"([a-zA-Z0-9_]+)\|(.+)", user)
if not match_user:
raise Exception(f"Could not parse Zephyr realm for cross-realm user {zulip_username}")
raise ValueError(f"Could not parse Zephyr realm for cross-realm user {zulip_username}")
return match_user.group(1).lower() + "@" + match_user.group(2).upper()


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


def process_loop(zulip_queue: "Queue[ZephyrDict]", log: Optional[IO[str]]) -> NoReturn:
Expand Down
2 changes: 1 addition & 1 deletion zulip_bots/zulip_bots/bots/xkcd/xkcd.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def fetch_xkcd_query(mode: int, comic_id: Optional[str] = None) -> Dict[str, str

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

fetched = requests.get(url)
Expand Down
4 changes: 2 additions & 2 deletions zulip_bots/zulip_bots/test_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ def unique_response(self) -> Dict[str, Any]:

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


class DefaultTests:
Expand Down

0 comments on commit a2ddac7

Please sign in to comment.