Skip to content
Myr

New status_code-based errors

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Kenneth Reitz · committed by Kenneth Reitz · parent e7a7615 · Browse files · 1 file+12 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+12 added−1 removed

  • other:+12 added−1 removed

1 file+12 added−1 removed

modified:requests/models.py+12 added-1 removed
20 unmodified lines
21from .packages.poster.encode import multipart_encode22from .packages.poster.streaminghttp import register_openers, get_handlers23from .utils import (dict_from_cookiejar, get_unicode_from_response, stream_decode_response_unicode, decode_gzip, stream_decode_gzip)24from .status_codes import codes25from .exceptions import Timeout, URLRequired, TooManyRedirects25from .exceptions import Timeout, URLRequired, TooManyRedirects, RequestException26from .monkeys import Request as _Request27from .monkeys import HTTPRedirectHandler2829from .auth import dispatch as auth_dispatch
483 unmodified lines
513514515 def raise_for_status(self):516 """Raises stored :class:`HTTPError` or :class:`URLError`, if one occurred."""517518 if self.error:519 raise self.error520521 if (self.status_code >= 300) and (self.status_code < 400):522 raise RequestException('%s Redirection' % self.status_code)523524 elif (self.status_code >= 400) and (self.status_code < 500):525 raise RequestException('%s Client Error' % self.status_code)526527 elif (self.status_code >= 500) and (self.status_code < 600):528 raise RequestException('%s Server Error' % self.status_code)529530