You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
1.7 KiB

# urllib3/exceptions.py
13 years ago
# Copyright 2008-2012 Andrey Petrov and contributors (see CONTRIBUTORS.txt)
#
# This module is part of urllib3 and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
13 years ago
13 years ago
## Base Exceptions
class HTTPError(Exception):
"Base exception used by this module."
pass
13 years ago
class PoolError(HTTPError):
"Base exception for errors caused within a pool."
def __init__(self, pool, message):
self.pool = pool
HTTPError.__init__(self, "%s: %s" % (pool, message))
class SSLError(HTTPError):
"Raised when SSL certificate fails in an HTTPS connection."
pass
13 years ago
## Leaf Exceptions
13 years ago
class MaxRetryError(PoolError):
"Raised when the maximum number of retries is exceeded."
13 years ago
13 years ago
def __init__(self, pool, url):
13 years ago
message = "Max retries exceeded with url: %s" % url
PoolError.__init__(self, pool, message)
13 years ago
self.url = url
13 years ago
class HostChangedError(PoolError):
"Raised when an existing pool gets a request for a foreign host."
13 years ago
13 years ago
def __init__(self, pool, url, retries=3):
13 years ago
message = "Tried to open a foreign host with url: %s" % url
PoolError.__init__(self, pool, message)
13 years ago
self.url = url
self.retries = retries
class TimeoutError(PoolError):
"Raised when a socket timeout occurs."
pass
13 years ago
class EmptyPoolError(PoolError):
"Raised when a pool runs out of connections and no more are allowed."
pass
13 years ago
class LocationParseError(ValueError, HTTPError):
"Raised when get_host or similar fails to parse the URL input."
def __init__(self, location):
message = "Failed to parse: %s" % location
super(LocationParseError, self).__init__(self, message)
self.location = location