Add better error logging for unexpected errors, add error messages for exceeded YouTube quota (#4552)

This commit is contained in:
jack1142
2020-10-28 12:37:56 +01:00
committed by GitHub
parent c95d526bc6
commit 4aa84a5d22
3 changed files with 47 additions and 13 deletions

View File

@@ -19,6 +19,7 @@ from .errors import (
OfflineStream,
StreamNotFound,
StreamsError,
YoutubeQuotaExceeded,
)
from . import streamtypes as _streamtypes
@@ -262,7 +263,19 @@ class Streams(commands.Cog):
"The YouTube API key is either invalid or has not been set. See {command}."
).format(command=f"`{ctx.clean_prefix}streamset youtubekey`")
)
except APIError:
except YoutubeQuotaExceeded:
await ctx.send(
_(
"YouTube quota has been exceeded."
" Try again later or contact the owner if this continues."
)
)
except APIError as e:
log.error(
"Something went wrong whilst trying to contact the stream service's API.\n"
"Raw response data:\n%r",
e,
)
await ctx.send(
_("Something went wrong whilst trying to contact the stream service's API.")
)
@@ -412,7 +425,19 @@ class Streams(commands.Cog):
).format(command=f"`{ctx.clean_prefix}streamset youtubekey`")
)
return
except APIError:
except YoutubeQuotaExceeded:
await ctx.send(
_(
"YouTube quota has been exceeded."
" Try again later or contact the owner if this continues."
)
)
except APIError as e:
log.error(
"Something went wrong whilst trying to contact the stream service's API.\n"
"Raw response data:\n%r",
e,
)
await ctx.send(
_("Something went wrong whilst trying to contact the stream service's API.")
)