Only grant permissions to new extensions from sync if they have the expected version
[chromium-blink-merge.git] / tools / telemetry / third_party / gsutilz / gslib / exception.py
blobfdaa7c33824792b4665d73a2673a33957fe46595
1 # -*- coding: utf-8 -*-
2 # Copyright 2010 Google Inc. All Rights Reserved.
4 # Permission is hereby granted, free of charge, to any person obtaining a
5 # copy of this software and associated documentation files (the
6 # "Software"), to deal in the Software without restriction, including
7 # without limitation the rights to use, copy, modify, merge, publish, dis-
8 # tribute, sublicense, and/or sell copies of the Software, and to permit
9 # persons to whom the Software is furnished to do so, subject to the fol-
10 # lowing conditions:
12 # The above copyright notice and this permission notice shall be included
13 # in all copies or substantial portions of the Software.
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
17 # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
18 # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 # IN THE SOFTWARE.
22 """gsutil exceptions.
24 The exceptions in this module are for use across multiple different classes.
25 """
27 from __future__ import absolute_import
30 class AbortException(StandardError):
31 """Exception raised when a user aborts a command that needs to do cleanup."""
33 def __init__(self, reason):
34 StandardError.__init__(self)
35 self.reason = reason
37 def __repr__(self):
38 return 'AbortException: %s' % self.reason
40 def __str__(self):
41 return 'AbortException: %s' % self.reason
44 class CommandException(StandardError):
45 """Exception raised when a problem is encountered running a gsutil command.
47 This exception should be used to signal user errors or system failures
48 (like timeouts), not bugs (like an incorrect param value). For the
49 latter you should raise Exception so we can see where/how it happened
50 via gsutil -D (which will include a stack trace for raised Exceptions).
51 """
53 def __init__(self, reason, informational=False):
54 """Instantiate a CommandException.
56 Args:
57 reason: Text describing the problem.
58 informational: Indicates reason should be printed as FYI, not a failure.
59 """
60 StandardError.__init__(self)
61 self.reason = reason
62 self.informational = informational
64 def __repr__(self):
65 return str(self)
67 def __str__(self):
68 return 'CommandException: %s' % self.reason
71 class HashMismatchException(Exception):
72 """Exception raised when data integrity validation fails."""
73 pass
76 class InvalidUrlError(Exception):
77 """Exception raised when URL is invalid."""
79 def __init__(self, message):
80 Exception.__init__(self, message)
81 self.message = message
83 def __repr__(self):
84 return str(self)
86 def __str__(self):
87 return 'InvalidUrlError: %s' % self.message