Commit 6fc121d9 authored by Fence's avatar Fence 🌈

add error handlers

parent 02b910bc
from flask import Flask
from minor.controller import ApiController, MusicController
from minor.error_handlers import set_error_handlers
class App(object):
def __init__(self, config):
self._flask = Flask(__name__)
self._flask.config['MONGODB_SETTINGS'] = {'db': 'minor'}
self._flask.config.update(config)
set_error_handlers(self._flask)
from minor.model import db
db.init_app(self._flask)
......
from flask import jsonify
def set_error_handlers(app):
@app.errorhandler(404)
def four_o_four(e):
return jsonify({"code": 404, "msg": "not found"}), 404
@app.errorhandler(500)
def five_hundred(e):
return jsonify({"code": 500, "msg": "internal error"}), 500
@app.errorhandler(403)
def verboten(e):
return jsonify({"code": 403, "msg": "verboten"}), 403
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment