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

Unified Diff: third_party/gsutil/gslib/exception.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
« no previous file with comments | « third_party/gsutil/gslib/devshell_auth_plugin.py ('k') | third_party/gsutil/gslib/file_part.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/gsutil/gslib/exception.py
diff --git a/third_party/gsutil/gslib/exception.py b/third_party/gsutil/gslib/exception.py
new file mode 100644
index 0000000000000000000000000000000000000000..fdaa7c33824792b4665d73a2673a33957fe46595
--- /dev/null
+++ b/third_party/gsutil/gslib/exception.py
@@ -0,0 +1,87 @@
+# -*- coding: utf-8 -*-
+# Copyright 2010 Google Inc. All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish, dis-
+# tribute, sublicense, and/or sell copies of the Software, and to permit
+# persons to whom the Software is furnished to do so, subject to the fol-
+# lowing conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
+# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+# IN THE SOFTWARE.
+"""gsutil exceptions.
+
+The exceptions in this module are for use across multiple different classes.
+"""
+
+from __future__ import absolute_import
+
+
+class AbortException(StandardError):
+ """Exception raised when a user aborts a command that needs to do cleanup."""
+
+ def __init__(self, reason):
+ StandardError.__init__(self)
+ self.reason = reason
+
+ def __repr__(self):
+ return 'AbortException: %s' % self.reason
+
+ def __str__(self):
+ return 'AbortException: %s' % self.reason
+
+
+class CommandException(StandardError):
+ """Exception raised when a problem is encountered running a gsutil command.
+
+ This exception should be used to signal user errors or system failures
+ (like timeouts), not bugs (like an incorrect param value). For the
+ latter you should raise Exception so we can see where/how it happened
+ via gsutil -D (which will include a stack trace for raised Exceptions).
+ """
+
+ def __init__(self, reason, informational=False):
+ """Instantiate a CommandException.
+
+ Args:
+ reason: Text describing the problem.
+ informational: Indicates reason should be printed as FYI, not a failure.
+ """
+ StandardError.__init__(self)
+ self.reason = reason
+ self.informational = informational
+
+ def __repr__(self):
+ return str(self)
+
+ def __str__(self):
+ return 'CommandException: %s' % self.reason
+
+
+class HashMismatchException(Exception):
+ """Exception raised when data integrity validation fails."""
+ pass
+
+
+class InvalidUrlError(Exception):
+ """Exception raised when URL is invalid."""
+
+ def __init__(self, message):
+ Exception.__init__(self, message)
+ self.message = message
+
+ def __repr__(self):
+ return str(self)
+
+ def __str__(self):
+ return 'InvalidUrlError: %s' % self.message
« no previous file with comments | « third_party/gsutil/gslib/devshell_auth_plugin.py ('k') | third_party/gsutil/gslib/file_part.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698