diff --git a/maloja/apis/native_v1.py b/maloja/apis/native_v1.py index 387df6b..66183fa 100644 --- a/maloja/apis/native_v1.py +++ b/maloja/apis/native_v1.py @@ -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":{ diff --git a/maloja/database/exceptions.py b/maloja/database/exceptions.py index 4a98d5c..534dc1e 100644 --- a/maloja/database/exceptions.py +++ b/maloja/database/exceptions.py @@ -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):