OLD | NEW |
(Empty) | |
| 1 # Copyright 2010 Google Inc. All Rights Reserved. |
| 2 # |
| 3 # Permission is hereby granted, free of charge, to any person obtaining a |
| 4 # copy of this software and associated documentation files (the |
| 5 # "Software"), to deal in the Software without restriction, including |
| 6 # without limitation the rights to use, copy, modify, merge, publish, dis- |
| 7 # tribute, sublicense, and/or sell copies of the Software, and to permit |
| 8 # persons to whom the Software is furnished to do so, subject to the fol- |
| 9 # lowing conditions: |
| 10 # |
| 11 # The above copyright notice and this permission notice shall be included |
| 12 # in all copies or substantial portions of the Software. |
| 13 # |
| 14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 15 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- |
| 16 # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT |
| 17 # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
| 18 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 19 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
| 20 # IN THE SOFTWARE. |
| 21 |
| 22 """gsutil exceptions.""" |
| 23 |
| 24 |
| 25 class AbortException(StandardError): |
| 26 """Exception raised when a user aborts a command that needs to do cleanup.""" |
| 27 |
| 28 def __init__(self, reason): |
| 29 StandardError.__init__(self) |
| 30 self.reason = reason |
| 31 |
| 32 def __repr__(self): |
| 33 return 'AbortException: %s' % self.reason |
| 34 |
| 35 def __str__(self): |
| 36 return 'AbortException: %s' % self.reason |
| 37 |
| 38 |
| 39 class CommandException(StandardError): |
| 40 """Exception raised when a problem is encountered running a gsutil command. |
| 41 |
| 42 This exception should be used to signal user errors or system failures |
| 43 (like timeouts), not bugs (like an incorrect param value). For the |
| 44 latter you should raise Exception so we can see where/how it happened |
| 45 via gsutil -D (which will include a stack trace for raised Exceptions). |
| 46 """ |
| 47 |
| 48 def __init__(self, reason, informational=False): |
| 49 """Instantiate a CommandException. |
| 50 |
| 51 Args: |
| 52 reason: Text describing the problem. |
| 53 informational: Indicates reason should be printed as FYI, not a failure. |
| 54 """ |
| 55 StandardError.__init__(self) |
| 56 self.reason = reason |
| 57 self.informational = informational |
| 58 |
| 59 def __repr__(self): |
| 60 return 'CommandException: %s' % self.reason |
| 61 |
| 62 def __str__(self): |
| 63 return 'CommandException: %s' % self.reason |
| 64 |
| 65 |
| 66 class ProjectIdException(StandardError): |
| 67 |
| 68 def __init__(self, reason): |
| 69 StandardError.__init__(self) |
| 70 self.reason = reason |
| 71 |
| 72 def __repr__(self): |
| 73 return 'ProjectIdException: %s' % self.reason |
| 74 |
| 75 def __str__(self): |
| 76 return 'ProjectIdException: %s' % self.reason |
OLD | NEW |