From 12b9dfbada992e0088a58a5ce475201971bf3008 Mon Sep 17 00:00:00 2001 From: administrator <7dn1yh5j@debauchez.fr> Date: Mon, 11 Dec 2023 19:49:06 +0100 Subject: [PATCH] Add Exception when images are requested from a source of a type that does not have any --- tubesync/common/errors.py | 7 +++++++ tubesync/sync/models.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tubesync/common/errors.py b/tubesync/common/errors.py index 130510a..2373da7 100644 --- a/tubesync/common/errors.py +++ b/tubesync/common/errors.py @@ -27,3 +27,10 @@ class DatabaseConnectionError(Exception): Raised when parsing or initially connecting to a database. ''' pass + + +class NoImageSourceException(Exception): + ''' + Raised when images are requested from a source of a type that does not have any. + ''' + pass diff --git a/tubesync/sync/models.py b/tubesync/sync/models.py index ce6d9dc..dceb38b 100644 --- a/tubesync/sync/models.py +++ b/tubesync/sync/models.py @@ -491,7 +491,7 @@ class Source(models.Model): @property def get_image_url(self): if self.source_type == self.SOURCE_TYPE_YOUTUBE_PLAYLIST: - raise Exception('This source is a playlist so it doesn\'t have thumbnail.') + raise NoImageSourceException('This source is a playlist so it doesn\'t have thumbnail.') return get_youtube_channel_image_info(self.url)