raise exceptions, map to http error codes

This commit is contained in:
dandds
2018-08-08 12:09:23 -04:00
parent 7b8934e0cb
commit d5ed99089c
4 changed files with 40 additions and 12 deletions

View File

@@ -14,3 +14,17 @@ class AlreadyExistsError(Exception):
@property
def message(self):
return "{} already exists".format(self.resource_name)
class UnauthorizedError(Exception):
def __init__(self, user, action):
self.user = user
self.action = action
@property
def message(self):
return "User {} not authorized to {}".format(self.user.id, self.action)
class UnauthenticatedError(Exception):
pass