Add multiple error route
This commit is contained in:
parent
e11a9811c9
commit
f2659b0010
@ -1,11 +1,11 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from borest import app, Route, Error
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from bottle import response, request
|
from bottle import response, request
|
||||||
|
|
||||||
from aore.search.fiasfactory import FiasFactory
|
from aore.search.fiasfactory import FiasFactory
|
||||||
from borest import app, Route, Error
|
|
||||||
|
|
||||||
|
|
||||||
class App(object):
|
class App(object):
|
||||||
@ -50,15 +50,7 @@ class App(object):
|
|||||||
return json.dumps(App._factory.gettext(aoid))
|
return json.dumps(App._factory.gettext(aoid))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@Error(404)
|
@Error([404, 500])
|
||||||
def basic_error_handler(error):
|
|
||||||
response.content_type = 'application/json'
|
|
||||||
response.set_header('Access-Control-Allow-Origin', '*')
|
|
||||||
|
|
||||||
return json.dumps(dict(error=error.status))
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
@Error(500)
|
|
||||||
def basic_error_handler(error):
|
def basic_error_handler(error):
|
||||||
response.content_type = 'application/json'
|
response.content_type = 'application/json'
|
||||||
response.set_header('Access-Control-Allow-Origin', '*')
|
response.set_header('Access-Control-Allow-Origin', '*')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user