parent
16f16e8a15
commit
2f3d77157b
1 changed files with 10 additions and 5 deletions
|
@ -1,7 +1,7 @@
|
||||||
import logging
|
import logging
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from flask import make_response
|
from flask import make_response, jsonify
|
||||||
from app import app
|
from app import app
|
||||||
from util.useremails import CannotSendEmailException
|
from util.useremails import CannotSendEmailException
|
||||||
from util.config.provider.baseprovider import CannotWriteConfigException
|
from util.config.provider.baseprovider import CannotWriteConfigException
|
||||||
|
@ -13,20 +13,25 @@ logger = logging.getLogger(__name__)
|
||||||
@app.errorhandler(model.DataModelException)
|
@app.errorhandler(model.DataModelException)
|
||||||
def handle_dme(ex):
|
def handle_dme(ex):
|
||||||
logger.exception(ex)
|
logger.exception(ex)
|
||||||
return make_response(json.dumps({'message': ex.message}), 400)
|
response = jsonify({'message': ex.message})
|
||||||
|
response.status_code = 400
|
||||||
|
return response
|
||||||
|
|
||||||
@app.errorhandler(CannotSendEmailException)
|
@app.errorhandler(CannotSendEmailException)
|
||||||
def handle_emailexception(ex):
|
def handle_emailexception(ex):
|
||||||
message = 'Could not send email. Please contact an administrator and report this problem.'
|
message = 'Could not send email. Please contact an administrator and report this problem.'
|
||||||
return make_response(json.dumps({'message': message}), 400)
|
response = jsonify({'message': message})
|
||||||
|
response.status_code = 400
|
||||||
|
return response
|
||||||
|
|
||||||
@app.errorhandler(CannotWriteConfigException)
|
@app.errorhandler(CannotWriteConfigException)
|
||||||
def handle_configexception(ex):
|
def handle_configexception(ex):
|
||||||
message = ('Configuration could not be written to the mounted volume. \n' +
|
message = ('Configuration could not be written to the mounted volume. \n' +
|
||||||
'Please make sure the mounted volume is not read-only and restart ' +
|
'Please make sure the mounted volume is not read-only and restart ' +
|
||||||
'the setup process. \n\nIssue: %s' % ex)
|
'the setup process. \n\nIssue: %s' % ex)
|
||||||
|
response = jsonify({'message': message})
|
||||||
return make_response(json.dumps({'message': message}), 400)
|
response.status_code = 400
|
||||||
|
return response
|
||||||
|
|
||||||
@app.errorhandler(model.TooManyLoginAttemptsException)
|
@app.errorhandler(model.TooManyLoginAttemptsException)
|
||||||
@crossdomain(origin='*', headers=['Authorization', 'Content-Type'])
|
@crossdomain(origin='*', headers=['Authorization', 'Content-Type'])
|
||||||
|
|
Reference in a new issue