|
1 #!/usr/bin/env python |
|
2 # |
|
3 # Copyright 2007 Google Inc. |
|
4 # |
|
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 |
|
8 # |
|
9 # http://www.apache.org/licenses/LICENSE-2.0 |
|
10 # |
|
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. |
|
16 # |
|
17 """Errors used in the urlfetch API |
|
18 developers. |
|
19 """ |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 class Error(Exception): |
|
27 """Base URL fetcher error type.""" |
|
28 |
|
29 |
|
30 class InvalidURLError(Error): |
|
31 """Raised when the URL given is empty or invalid. |
|
32 |
|
33 Only http: and https: URLs are allowed. The maximum URL length |
|
34 allowed is 2048 characters. The login/pass portion is not |
|
35 allowed. In deployed applications, only ports 80 and 443 for http |
|
36 and https respectively are allowed. |
|
37 """ |
|
38 |
|
39 |
|
40 class DownloadError(Error): |
|
41 """Raised when the we could not fetch the URL for any reason. |
|
42 |
|
43 Note that this exception is only raised when we could not contact the |
|
44 server. HTTP errors (e.g., 404) are returned in as the status_code field |
|
45 in the return value of Fetch, and no exception is raised. |
|
46 """ |
|
47 |
|
48 |
|
49 class ResponseTooLargeError(Error): |
|
50 """Raised when the response was too large and was truncated.""" |
|
51 def __init__(self, response): |
|
52 self.response = response |
|
53 |
|
54 |
|
55 class InvalidMethodError(Error): |
|
56 """Raised when an invalid value for 'method' is provided""" |
|
57 |
|
58 |
|
59 class InvalidMethodError(Error): |
|
60 """Raised when an invalid value for 'method' is provided""" |