Exemple #1
0
    def requests_unusual_status(e):
        status_code = e.response.status_code
        status_text = e.response.reason

        if status_code == 404:
            LOG.exception("Backend responded that resource doesn't exist: %s",
                          e.request)
            return call_error("The backend server did not respond properly",
                              503)
        if status_code == 409:
            LOG.exception('Backend rejected, the input that was given: %s',
                          e.request)
            return call_error(
                "The information you submit was invalid for an unspecified reason. Try something else.",
                409)
        if status_code == 500:
            LOG.exception(
                'Cannot service response due to a fault in a dependent service'
            )
            return call_error(
                "The backend server failed to respond as expected", 503)
        if status_code == 502:
            LOG.exception('Backend server responded as Bad Gateway')
            return call_error(
                "The backend server failed to respond try again in a few minutes",
                503)

        return general_exception(e)
Exemple #2
0
 def server_error(e):
     LOG.exception('An error occurred during a request.')
     return call_error(e.description, 500)
Exemple #3
0
 def server_error(e):
     LOG.exception('Wrong method was used')
     return call_error("Method Not Allowed", 405)
Exemple #4
0
 def server_error(e):
     LOG.exception('Requested something that doesn\'t exist')
     return call_error(e.description, 404)
Exemple #5
0
 def server_error(e):
     LOG.exception('An invalid request was made')
     return call_error(e.description, 400)
Exemple #6
0
 def general_exception(e):
     LOG.exception('Unexpected exception')
     return call_error(
         "Unexpected exception happened. No details available", 500)