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

Unified Diff: third_party/gsutil/third_party/apitools/apitools/base/py/exceptions.py

Issue 1377933002: [catapult] - Copy Telemetry's gsutilz over to third_party. (Closed) Base URL: https://github.com/catapult-project/catapult.git@master
Patch Set: Rename to gsutil. Created 5 years, 3 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: third_party/gsutil/third_party/apitools/apitools/base/py/exceptions.py
diff --git a/third_party/gsutil/third_party/apitools/apitools/base/py/exceptions.py b/third_party/gsutil/third_party/apitools/apitools/base/py/exceptions.py
new file mode 100755
index 0000000000000000000000000000000000000000..1d736197c0608a1f5f347708cec960d865d659ce
--- /dev/null
+++ b/third_party/gsutil/third_party/apitools/apitools/base/py/exceptions.py
@@ -0,0 +1,148 @@
+#!/usr/bin/env python
+"""Exceptions for generated client libraries."""
+
+
+class Error(Exception):
+
+ """Base class for all exceptions."""
+
+
+class TypecheckError(Error, TypeError):
+
+ """An object of an incorrect type is provided."""
+
+
+class NotFoundError(Error):
+
+ """A specified resource could not be found."""
+
+
+class UserError(Error):
+
+ """Base class for errors related to user input."""
+
+
+class InvalidDataError(Error):
+
+ """Base class for any invalid data error."""
+
+
+class CommunicationError(Error):
+
+ """Any communication error talking to an API server."""
+
+
+class HttpError(CommunicationError):
+
+ """Error making a request. Soon to be HttpError."""
+
+ def __init__(self, response, content, url):
+ super(HttpError, self).__init__()
+ self.response = response
+ self.content = content
+ self.url = url
+
+ def __str__(self):
+ content = self.content.decode('ascii', 'replace')
+ return 'HttpError accessing <%s>: response: <%s>, content <%s>' % (
+ self.url, self.response, content)
+
+ @property
+ def status_code(self):
+ # TODO(craigcitro): Turn this into something better than a
+ # KeyError if there is no status.
+ return int(self.response['status'])
+
+ @classmethod
+ def FromResponse(cls, http_response):
+ return cls(http_response.info, http_response.content,
+ http_response.request_url)
+
+
+class InvalidUserInputError(InvalidDataError):
+
+ """User-provided input is invalid."""
+
+
+class InvalidDataFromServerError(InvalidDataError, CommunicationError):
+
+ """Data received from the server is malformed."""
+
+
+class BatchError(Error):
+
+ """Error generated while constructing a batch request."""
+
+
+class ConfigurationError(Error):
+
+ """Base class for configuration errors."""
+
+
+class GeneratedClientError(Error):
+
+ """The generated client configuration is invalid."""
+
+
+class ConfigurationValueError(UserError):
+
+ """Some part of the user-specified client configuration is invalid."""
+
+
+class ResourceUnavailableError(Error):
+
+ """User requested an unavailable resource."""
+
+
+class CredentialsError(Error):
+
+ """Errors related to invalid credentials."""
+
+
+class TransferError(CommunicationError):
+
+ """Errors related to transfers."""
+
+
+class TransferRetryError(TransferError):
+
+ """Retryable errors related to transfers."""
+
+
+class TransferInvalidError(TransferError):
+
+ """The given transfer is invalid."""
+
+
+class RequestError(CommunicationError):
+
+ """The request was not successful."""
+
+
+class RetryAfterError(HttpError):
+
+ """The response contained a retry-after header."""
+
+ def __init__(self, response, content, url, retry_after):
+ super(RetryAfterError, self).__init__(response, content, url)
+ self.retry_after = int(retry_after)
+
+ @classmethod
+ def FromResponse(cls, http_response):
+ return cls(http_response.info, http_response.content,
+ http_response.request_url, http_response.retry_after)
+
+
+class BadStatusCodeError(HttpError):
+
+ """The request completed but returned a bad status code."""
+
+
+class NotYetImplementedError(GeneratedClientError):
+
+ """This functionality is not yet implemented."""
+
+
+class StreamExhausted(Error):
+
+ """Attempted to read more bytes from a stream than were available."""

Powered by Google App Engine
This is Rietveld 408576698