From b657892b3b624961b41b47632c78d3ba8d644f39 Mon Sep 17 00:00:00 2001 From: Benjamin Mintz Date: Mon, 10 Jun 2019 23:42:44 +0000 Subject: [PATCH] fix errors when timing out while resizing --- cogs/emote.py | 2 ++ utils/errors.py | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cogs/emote.py b/cogs/emote.py index 37edb31..4b2d78d 100644 --- a/cogs/emote.py +++ b/cogs/emote.py @@ -171,6 +171,8 @@ class Emotes(commands.Cog): return ( 'An error occurred while creating the emote:\n' + utils.format_http_exception(ex)) + except errors.ImageResizeTimeoutError: + raise except asyncio.TimeoutError: return 'Error: retrieving the image took too long.' except ValueError: diff --git a/utils/errors.py b/utils/errors.py index b3a323f..d43aaf6 100644 --- a/utils/errors.py +++ b/utils/errors.py @@ -1,5 +1,4 @@ -#!/usr/bin/env python3 -# encoding: utf-8 +import asyncio from discord.ext import commands @@ -19,6 +18,11 @@ class EmoteManagerError(commands.CommandError): """Generic error with the bot. This can be used to catch all bot errors.""" pass +class ImageResizeTimeoutError(EmoteManagerError, asyncio.TimeoutError): + """Resizing the image took too long.""" + def __init__(self): + super().__init__('Error: resizing the image took too long.') + class HTTPException(EmoteManagerError): """The server did not respond with an OK status code.""" def __init__(self, status):