-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Labels
Description
I've not delved too deep into this yet, so I'm not sure how straight forward this would be to implement...
Having the ability to use exceptions to return an error response (and correct HTTP response code) would be extremely useful. A pseudo example:
Exception class:
class UnauthorizedException(ChaliceError):
STATUS_CODE = 401
App logic:
if not authenticate(user):
raise UnauthorizedException('You are not authenticated')
Response example (inc. correct response headers):
{"error": e.message}
Having quickly checked the source code, it looks like it should just be a cause of creating the exceptions and adding them to the ALL_ERRORS list.
Thoughts?
daneah and woodlandh