From 8da6f0d8deb8409aeb9fe953d7708e47051bdbea Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Thu, 1 Feb 2024 19:25:02 -0500 Subject: [PATCH] fix(bible): added error message for if a passage cannot be found --- bible/bible.py | 4 +++- bible/errors.py | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/bible/bible.py b/bible/bible.py index d518292..a53bc23 100644 --- a/bible/bible.py +++ b/bible/bible.py @@ -13,7 +13,7 @@ from discord import Embed from redbot.core import Config, commands from redbot.core.bot import Red -from bible.errors import BibleAccessError, Unauthorized +from bible.errors import BibleAccessError, NotFound, Unauthorized class Bible(commands.Cog): @@ -73,6 +73,8 @@ class Bible(commands.Cog): raise BibleAccessError( "The provided API key cannot retrieve sections from the configured Bible." ) + if response.status == 404: + raise NotFound("The requested passage was not found.") data = await response.json() return data["data"] diff --git a/bible/errors.py b/bible/errors.py index 0bbb571..ac9d9f0 100644 --- a/bible/errors.py +++ b/bible/errors.py @@ -4,3 +4,7 @@ class BibleAccessError(Exception): class Unauthorized(Exception): pass + + +class NotFound(Exception): + pass