New package structure for the version 2 of the public api.

Start building up the validators required for post notificaiton.
The app/v2/errors.py is a rough sketch, will be passed a code, the error can look up the message and link for the error message.
This commit is contained in:
Rebecca Law
2016-10-25 18:04:03 +01:00
parent a5e07d8aff
commit 23a4f00e56
9 changed files with 199 additions and 1 deletions

29
app/v2/errors.py Normal file
View File

@@ -0,0 +1,29 @@
from flask import jsonify
from app.errors import InvalidRequest
class BadRequestError(Exception):
status_code = 400
def __init__(self, message, fields, code):
self.code = code
self.message = message
self.fields = fields
def register_errors(blueprint):
@blueprint.app_errorhandler(Exception)
def authentication_error(error):
# v2 error format - NOT this
return jsonify(result='error', message=error.message), error.code
@blueprint.app_errorhandler(InvalidRequest)
def handle_invalid_request(error):
# {
# "code",
# "link",
# "message" ,
# "fields":
# }
return "build_error_message"