Ejemplo n.º 1
0
    def handle_unprocessable_entity(error):
        name = 'Unprocessable Entity'
        data = getattr(error, 'data')
        if data:
            # Get validations from the ValidationError object
            messages = data['messages']
        else:
            messages = ['Invalid request']

        if _is_api(request):
            return make_error_json(error, name, 422)
        else:
            return make_error_page(app,
                                   name,
                                   422,
                                   sentry=sentry,
                                   data=messages)
Ejemplo n.º 2
0
 def method_not_allowed(error):
     name = 'Method Not Allowed'
     if _is_api(request):
         return make_error_json(error, name, 405)
     else:
         return make_error_page(app, name, 405, sentry=sentry)
Ejemplo n.º 3
0
 def internal_server_error(error):
     name = 'Internal Server Error'
     if _is_api(request):
         return make_error_json(error, name, 500)
     else:
         return make_error_page(app, name, 500, sentry=sentry)
Ejemplo n.º 4
0
 def bad_request(error):
     name = 'Bad Request'
     if _is_api(request):
         return make_error_json(error, name, 400)
     else:
         return make_error_page(app, name, 400, sentry=sentry)
Ejemplo n.º 5
0
 def page_not_found(error):
     name = 'Page Not Found'
     if _is_api(request):
         return make_error_json(error, name, 404)
     else:
         return make_error_page(app, name, 404, sentry=sentry)