| Home | Trees | Indices | Help |
|---|
|
|
1 #!/usr/bin/python2.4 2 # 3 # Copyright 2014 Google Inc. All Rights Reserved. 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 for the library. 18 19 All exceptions defined by the library 20 should be defined in this file. 21 """ 22 23 __author__ = 'jcgregorio@google.com (Joe Gregorio)' 24 25 26 from oauth2client import util 27 from oauth2client.anyjson import simplejson 3336 """HTTP data was invalid or unexpected.""" 37 38 @util.positional(3) 4364 69 74 79 84 89 94 99 104 10845 """Calculate the reason for the error from the response content.""" 46 reason = self.resp.reason 47 try: 48 data = simplejson.loads(self.content) 49 reason = data['error']['message'] 50 except (ValueError, KeyError): 51 pass 52 if reason is None: 53 reason = '' 54 return reason5557 if self.uri: 58 return '<HttpError %s when requesting %s returned "%s">' % ( 59 self.resp.status, self.uri, self._get_reason().strip()) 60 else: 61 return '<HttpError %s "%s">' % (self.resp.status, self._get_reason())62 63 __str__ = __repr__110 """Error occured during batch operations.""" 111 112 @util.positional(2) 117 120 121 __str__ = __repr__122125 """Exception raised by RequestMockBuilder on unexpected calls.""" 126 127 @util.positional(1)132129 """Constructor for an UnexpectedMethodError.""" 130 super(UnexpectedMethodError, self).__init__( 131 'Received unexpected call %s' % methodId)135 """Exception raised by RequestMockBuilder on unexpected bodies.""" 136141138 """Constructor for an UnexpectedMethodError.""" 139 super(UnexpectedBodyError, self).__init__( 140 'Expected: [%s] - Provided: [%s]' % (expected, provided))
| Home | Trees | Indices | Help |
|---|
| Generated by Epydoc 3.0.1 on Thu Aug 14 00:45:19 2014 | http://epydoc.sourceforge.net |