Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1480)

Unified Diff: appengine/chromium_build_logs/third_party/googleapiclient/errors.py

Issue 1260293009: make version of ts_mon compatible with appengine (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: clean up code Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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__(

Powered by Google App Engine
This is Rietveld 408576698