How to use the fastly.errors.InternalServerError function in fastly

To help you get started, we’ve selected a few fastly examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fastly / fastly-py / fastly / connection.py View on Github external
if self.authenticator:
            self.authenticator.add_auth(headers)

        self.http_conn.request(method, self.root + path, body, headers=headers)
        response = self.http_conn.getresponse()
        body = response.read().decode('utf-8')
        try:
            data = json.loads(body)
        except ValueError:
            data = body

        if response.status in [401, 403]:
            raise errors.AuthenticationError()
        elif response.status == 500:
            raise errors.InternalServerError()
        elif response.status == 400:
            raise errors.BadRequestError(body)
        elif response.status == 404:
            raise errors.NotFoundError()

        return (response, data)