Add Exception when images are requested from a source of a type that does not have any

This commit is contained in:
administrator 2023-12-11 19:49:06 +01:00
parent 32a884365b
commit 12b9dfbada
2 changed files with 8 additions and 1 deletions

View File

@ -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

View File

@ -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)