1.9.30 sync.
[gae.git] / python / google / appengine / api / urlfetch_errors.py
blob88dc80a2f016180b7491cadbc75c6e8d53ee2845
1 #!/usr/bin/env python
3 # Copyright 2007 Google Inc.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
20 """Errors used in the urlfetch API
21 developers.
22 """
35 class Error(Exception):
36 """Base URL fetcher error type."""
38 class DownloadError(Error):
39 """Raised when we could not fetch the URL for any reason.
41 Note that this exception is only raised when we cannot contact the
42 server. HTTP errors (e.g., 404) are returned in the status_code field
43 in the return value of fetch, and no exception is raised.
44 """
46 class MalformedReplyError(DownloadError):
47 """Raised when the target server returns an invalid HTTP response.
49 Responses are invalid if they contain no headers, malformed or
50 incomplete headers, or have content missing.
51 """
53 class TooManyRedirectsError(DownloadError):
54 """Raised when follow_redirects input parameter was set to true and the
55 redirect limit was hit."""
57 class InternalTransientError(Error):
58 """Raised when an internal transient error occurs."""
60 class ConnectionClosedError(DownloadError):
61 """Raised when the target server prematurely closes the connection."""
63 class InvalidURLError(Error):
64 """Raised when the URL given is empty or invalid.
66 Only http: and https: URLs are allowed. The maximum URL length
67 allowed is 2048 characters. The login/pass portion is not
68 allowed. In deployed applications, only ports 80 and 443 for http
69 and https respectively are allowed.
70 """
72 class DNSLookupFailedError(DownloadError):
73 """Raised when the DNS lookup for a URL failed."""
75 class DeadlineExceededError(DownloadError):
76 """Raised when we could not fetch the URL because the deadline was exceeded.
78 This can occur with either the client-supplied 'deadline' or the system
79 default, if the client does not supply a 'deadline' parameter.
80 """
82 class ResponseTooLargeError(Error):
83 """Raised when the response was too large and was truncated."""
84 def __init__(self, response):
85 self.response = response
87 class InvalidMethodError(Error):
88 """Raised when an invalid value for 'method' is provided"""
90 class SSLCertificateError(Error):
91 """Raised when an invalid server certificate is presented."""