diff --git a/maloja/apis/native_v1.py b/maloja/apis/native_v1.py index a1776ed..5d54f7f 100644 --- a/maloja/apis/native_v1.py +++ b/maloja/apis/native_v1.py @@ -47,6 +47,14 @@ errors = { 'desc':"A scrobble requires these parameters." } }), + database.exceptions.EntityExists: lambda e: (409,{ + "status":"failure", + "error":{ + 'type':'entity_exists', + 'value':e.entitydict, + 'desc':"This entity already exists in the database." + } + }), Exception: lambda e: (500,{ "status":"failure", "error":{ diff --git a/maloja/database/exceptions.py b/maloja/database/exceptions.py new file mode 100644 index 0000000..7273643 --- /dev/null +++ b/maloja/database/exceptions.py @@ -0,0 +1,10 @@ +class EntityExists(Exception): + def __init__(self,entitydict): + self.entitydict = entitydict + + +class TrackExists(EntityExists): + pass + +class ArtistExists(EntityExists): + pass