| Index: appengine/chromium_build_logs/third_party/googleapiclient/errors.py
|
| diff --git a/appengine/chromium_build_logs/third_party/apiclient/errors.py b/appengine/chromium_build_logs/third_party/googleapiclient/errors.py
|
| similarity index 75%
|
| rename from appengine/chromium_build_logs/third_party/apiclient/errors.py
|
| rename to appengine/chromium_build_logs/third_party/googleapiclient/errors.py
|
| index b6ee9a5bb1e7da022a50d7c1d0aa531ad36d58fd..3d44de7006254ed3663e21b527d2eec9f79ee656 100644
|
| --- a/appengine/chromium_build_logs/third_party/apiclient/errors.py
|
| +++ b/appengine/chromium_build_logs/third_party/googleapiclient/errors.py
|
| @@ -1,6 +1,4 @@
|
| -#!/usr/bin/python2.4
|
| -#
|
| -# Copyright (C) 2010 Google Inc.
|
| +# Copyright 2014 Google Inc. All Rights Reserved.
|
| #
|
| # Licensed under the Apache License, Version 2.0 (the "License");
|
| # you may not use this file except in compliance with the License.
|
| @@ -19,11 +17,13 @@
|
| All exceptions defined by the library
|
| should be defined in this file.
|
| """
|
| +from __future__ import absolute_import
|
|
|
| __author__ = 'jcgregorio@google.com (Joe Gregorio)'
|
|
|
| +import json
|
|
|
| -from oauth2client.anyjson import simplejson
|
| +from oauth2client import util
|
|
|
|
|
| class Error(Exception):
|
| @@ -34,27 +34,30 @@ class Error(Exception):
|
| class HttpError(Error):
|
| """HTTP data was invalid or unexpected."""
|
|
|
| + @util.positional(3)
|
| def __init__(self, resp, content, uri=None):
|
| self.resp = resp
|
| + if not isinstance(content, bytes):
|
| + raise TypeError("HTTP content should be bytes")
|
| self.content = content
|
| self.uri = uri
|
|
|
| def _get_reason(self):
|
| """Calculate the reason for the error from the response content."""
|
| - if self.resp.get('content-type', '').startswith('application/json'):
|
| - try:
|
| - data = simplejson.loads(self.content)
|
| - reason = data['error']['message']
|
| - except (ValueError, KeyError):
|
| - reason = self.content
|
| - else:
|
| - reason = self.resp.reason
|
| + reason = self.resp.reason
|
| + try:
|
| + data = json.loads(self.content.decode('utf-8'))
|
| + reason = data['error']['message']
|
| + except (ValueError, KeyError):
|
| + pass
|
| + if reason is None:
|
| + reason = ''
|
| return reason
|
|
|
| def __repr__(self):
|
| if self.uri:
|
| return '<HttpError %s when requesting %s returned "%s">' % (
|
| - self.resp.status, self.uri, self._get_reason())
|
| + self.resp.status, self.uri, self._get_reason().strip())
|
| else:
|
| return '<HttpError %s "%s">' % (self.resp.status, self._get_reason())
|
|
|
| @@ -66,6 +69,11 @@ class InvalidJsonError(Error):
|
| pass
|
|
|
|
|
| +class UnknownFileType(Error):
|
| + """File type unknown or unexpected."""
|
| + pass
|
| +
|
| +
|
| class UnknownLinkType(Error):
|
| """Link type unknown or unexpected."""
|
| pass
|
| @@ -86,14 +94,23 @@ class MediaUploadSizeError(Error):
|
| pass
|
|
|
|
|
| -class ResumableUploadError(Error):
|
| +class ResumableUploadError(HttpError):
|
| """Error occured during resumable upload."""
|
| pass
|
|
|
|
|
| +class InvalidChunkSizeError(Error):
|
| + """The given chunksize is not valid."""
|
| + pass
|
| +
|
| +class InvalidNotificationError(Error):
|
| + """The channel Notification is invalid."""
|
| + pass
|
| +
|
| class BatchError(HttpError):
|
| """Error occured during batch operations."""
|
|
|
| + @util.positional(2)
|
| def __init__(self, reason, resp=None, content=None):
|
| self.resp = resp
|
| self.content = content
|
| @@ -108,6 +125,7 @@ class BatchError(HttpError):
|
| class UnexpectedMethodError(Error):
|
| """Exception raised by RequestMockBuilder on unexpected calls."""
|
|
|
| + @util.positional(1)
|
| def __init__(self, methodId=None):
|
| """Constructor for an UnexpectedMethodError."""
|
| super(UnexpectedMethodError, self).__init__(
|
|
|