fix(bible): added inexplicableerror and handling for it

This commit is contained in:
Seaswimmer 2024-02-02 02:10:06 -05:00
parent 09302403b8
commit fda80d4e41
Signed by untrusted user: cswimr
GPG key ID: B8953EC01E5C4063
2 changed files with 15 additions and 0 deletions

View file

@ -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:

View file

@ -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