OLD | NEW |
(Empty) | |
| 1 import sys |
| 2 import json |
| 3 from boto.exception import BotoServerError |
| 4 |
| 5 |
| 6 def simple(e): |
| 7 err = json.loads(e.error_message) |
| 8 code = err['Error']['Code'] |
| 9 |
| 10 try: |
| 11 # Dynamically get the error class. |
| 12 simple_e = getattr(sys.modules[__name__], code)(e, err) |
| 13 except AttributeError: |
| 14 # Return original exception on failure. |
| 15 return e |
| 16 |
| 17 return simple_e |
| 18 |
| 19 |
| 20 class SimpleException(BotoServerError): |
| 21 def __init__(self, e, err): |
| 22 super(SimpleException, self).__init__(e.status, e.reason, e.body) |
| 23 self.body = e.error_message |
| 24 self.request_id = err['RequestId'] |
| 25 self.error_code = err['Error']['Code'] |
| 26 self.error_message = err['Error']['Message'] |
| 27 |
| 28 def __repr__(self): |
| 29 return self.__class__.__name__ + ': ' + self.error_message |
| 30 def __str__(self): |
| 31 return self.__class__.__name__ + ': ' + self.error_message |
| 32 |
| 33 |
| 34 class ValidationError(SimpleException): pass |
| 35 |
| 36 # Common beanstalk exceptions. |
| 37 class IncompleteSignature(SimpleException): pass |
| 38 class InternalFailure(SimpleException): pass |
| 39 class InvalidAction(SimpleException): pass |
| 40 class InvalidClientTokenId(SimpleException): pass |
| 41 class InvalidParameterCombination(SimpleException): pass |
| 42 class InvalidParameterValue(SimpleException): pass |
| 43 class InvalidQueryParameter(SimpleException): pass |
| 44 class MalformedQueryString(SimpleException): pass |
| 45 class MissingAction(SimpleException): pass |
| 46 class MissingAuthenticationToken(SimpleException): pass |
| 47 class MissingParameter(SimpleException): pass |
| 48 class OptInRequired(SimpleException): pass |
| 49 class RequestExpired(SimpleException): pass |
| 50 class ServiceUnavailable(SimpleException): pass |
| 51 class Throttling(SimpleException): pass |
| 52 |
| 53 |
| 54 # Action specific exceptions. |
| 55 class TooManyApplications(SimpleException): pass |
| 56 class InsufficientPrivileges(SimpleException): pass |
| 57 class S3LocationNotInServiceRegion(SimpleException): pass |
| 58 class TooManyApplicationVersions(SimpleException): pass |
| 59 class TooManyConfigurationTemplates(SimpleException): pass |
| 60 class TooManyEnvironments(SimpleException): pass |
| 61 class S3SubscriptionRequired(SimpleException): pass |
| 62 class TooManyBuckets(SimpleException): pass |
| 63 class OperationInProgress(SimpleException): pass |
| 64 class SourceBundleDeletion(SimpleException): pass |
OLD | NEW |