From fda80d4e41c4382fb5cec68335efe1d817288096 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Fri, 2 Feb 2024 02:10:06 -0500 Subject: [PATCH] fix(bible): added inexplicableerror and handling for it --- bible/bible.py | 4 ++++ bible/errors.py | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/bible/bible.py b/bible/bible.py index 1f03395..6b26d1f 100644 --- a/bible/bible.py +++ b/bible/bible.py @@ -74,6 +74,8 @@ class Bible(commands.Cog): "_get_passage executed with a response code of: %s", response.status, ) + if response.status == 400: + raise bible.errors.InexplicableError() if response.status == 401: raise bible.errors.Unauthorized() if response.status == 403: @@ -193,6 +195,7 @@ class Bible(commands.Cog): except ( bible.errors.BibleAccessError, bible.errors.NotFound, + bible.errors.InexplicableError, bible.errors.ServiceUnavailable, bible.errors.Unauthorized, ) as e: @@ -233,6 +236,7 @@ class Bible(commands.Cog): except ( bible.errors.BibleAccessError, bible.errors.NotFound, + bible.errors.InexplicableError, bible.errors.ServiceUnavailable, bible.errors.Unauthorized, ) as e: diff --git a/bible/errors.py b/bible/errors.py index c4c0592..04b5e06 100644 --- a/bible/errors.py +++ b/bible/errors.py @@ -39,3 +39,14 @@ class ServiceUnavailable(Exception): ): super().__init__(message) self.message = message + + +class InexplicableError(Exception): + def __init__( + self, + message: str = error( + "An explicable 'Bad Request' error occurred. This error happens occassionally with the API.Bible service. Please try again. If the error persists, please report this to the bot owner." + ), + ): + super().__init__(message) + self.message = message