| OLD | NEW |
| (Empty) | |
| 1 # Copyright (c) 2012 Andy Davidoff http://www.disruptek.com/ |
| 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 from boto.exception import BotoServerError |
| 22 |
| 23 |
| 24 class ResponseErrorFactory(BotoServerError): |
| 25 |
| 26 def __new__(cls, *args, **kw): |
| 27 error = BotoServerError(*args, **kw) |
| 28 try: |
| 29 newclass = globals()[error.error_code] |
| 30 except KeyError: |
| 31 newclass = ResponseError |
| 32 obj = newclass.__new__(newclass, *args, **kw) |
| 33 obj.__dict__.update(error.__dict__) |
| 34 return obj |
| 35 |
| 36 |
| 37 class ResponseError(BotoServerError): |
| 38 """ |
| 39 Undefined response error. |
| 40 """ |
| 41 retry = False |
| 42 |
| 43 def __repr__(self): |
| 44 return '{0}({1}, {2},\n\t{3})'.format(self.__class__.__name__, |
| 45 self.status, self.reason, |
| 46 self.error_message) |
| 47 |
| 48 def __str__(self): |
| 49 return 'MWS Response Error: {0.status} {0.__class__.__name__} {1}\n' \ |
| 50 '{2}\n' \ |
| 51 '{0.error_message}'.format(self, |
| 52 self.retry and '(Retriable)' or '', |
| 53 self.__doc__.strip()) |
| 54 |
| 55 |
| 56 class RetriableResponseError(ResponseError): |
| 57 retry = True |
| 58 |
| 59 |
| 60 class InvalidParameterValue(ResponseError): |
| 61 """ |
| 62 One or more parameter values in the request is invalid. |
| 63 """ |
| 64 |
| 65 |
| 66 class InvalidParameter(ResponseError): |
| 67 """ |
| 68 One or more parameters in the request is invalid. |
| 69 """ |
| 70 |
| 71 |
| 72 class InvalidAddress(ResponseError): |
| 73 """ |
| 74 Invalid address. |
| 75 """ |
| OLD | NEW |