Exceptions

This commit is contained in:
krateng 2023-10-28 13:11:45 +02:00
parent abc48a04c8
commit 5524ee5aef
2 changed files with 13 additions and 3 deletions

View File

@ -72,6 +72,14 @@ errors = {
'desc':"The database is being upgraded. Please try again later."
}
}),
database.exceptions.EntityDoesNotExist: lambda e: (404,{
"status":"error",
"error":{
'type':'entity_does_not_exist',
'value':e.entitydict,
'desc':"This entity does not exist in the database."
}
}),
images.MalformedB64: lambda e: (400,{
"status":"failure",
"error":{

View File

@ -11,6 +11,8 @@ class TrackExists(EntityExists):
class ArtistExists(EntityExists):
pass
class AlbumExists(EntityExists):
pass
class DatabaseNotBuilt(HTTPError):
def __init__(self):
@ -30,11 +32,11 @@ class MissingEntityParameter(Exception):
class EntityDoesNotExist(HTTPError):
entitytype = 'Entity'
def __init__(self,name):
self.entityname = name
def __init__(self,entitydict):
self.entitydict = entitydict
super().__init__(
status=404,
body=f"The {self.entitytype} '{self.entityname}' does not exist in the database."
body=f"The {self.entitytype} '{self.entitydict}' does not exist in the database."
)
class ArtistDoesNotExist(EntityDoesNotExist):