From ccb96255482ebd2de9d2ee0fd09ec79ecfac4d35 Mon Sep 17 00:00:00 2001 From: Marco S <70583350+MarcoSa-2000@users.noreply.github.com> Date: Wed, 10 May 2023 16:34:20 +0200 Subject: [PATCH] 0.5.2 --- animegifs/animegifs.py | 6 ++++-- animegifs/distutils/errors.py | 36 +++++++++++++++++++++++++++++++---- setup.py | 2 +- 3 files changed, 37 insertions(+), 7 deletions(-) diff --git a/animegifs/animegifs.py b/animegifs/animegifs.py index 77baca4..5efbce0 100644 --- a/animegifs/animegifs.py +++ b/animegifs/animegifs.py @@ -46,10 +46,12 @@ def get_gif(self, category: str) -> str: gif: gif (url) -> str """ if type(category) is int: - raise errors.CategoryIntegral + raise errors.CategoryIntegral(category) elif category.lower() in gifs_dict: gif = gifs_dict[category.lower()] + elif category.lower() not in gifs_dict: + raise errors.CategoryError(category) else: - raise errors.CategoryError + raise errors.CategoryUnknown(category) return gif \ No newline at end of file diff --git a/animegifs/distutils/errors.py b/animegifs/distutils/errors.py index 9288fc6..2decc57 100644 --- a/animegifs/distutils/errors.py +++ b/animegifs/distutils/errors.py @@ -1,5 +1,33 @@ -class CategoryIntegral: - """Category can't be an integral.""" +class CategoryIntegral(Exception): + """ + Category can't be an integral, only a string. + You can check valid categories at: https://github.com/MarcoSa-2000/animegifs + """ -class CategoryError: - """Not a valid category. You can check valid categories at: https://github.com/MarcoSa-2000/animegifs""" + def __init__(self, category, error="Category can't be an integral."): + self.category = category + self.error = error + super().__init__(self.error) + +class CategoryError(Exception): + """ + Not a valid category. Category must be a string. + You can check valid categories at: https://github.com/MarcoSa-2000/animegifs + """ + + def __init__(self, category, error="Not a valid category."): + self.category = category + self.error = error + super().__init__(self.error) + +class CategoryUnknown(Exception): + """ + This is a not handled error, probably the category type is neither an int nor a str. + Make sure to check category is a string and is a valid category. + You can check valid categories at: https://github.com/MarcoSa-2000/animegifs + """ + + def __init__(self, category, error="Not a valid category."): + self.category = category + self.error = error + super().__init__(self.error) diff --git a/setup.py b/setup.py index 3a665db..18955d3 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ long_description = "\n" + fh.read() LONG_DESCRIPTION = long_description -VERSION = '0.5.1' +VERSION = '0.5.2' setup( name='animegifs',