import json


class Error(Exception):
    """This is an ambiguous error that occured."""
    pass

class SyncUnallowedError(Error): pass

class DuplicateBatchItemError(Error): pass

class IncompleteSolventError(Error): pass

class ExceededBatchRequestsError(Error): pass

class ItemNotFoundError(Error): pass

class DynamoDBError(Error): pass

class ProvisionedThroughputError(DynamoDBError): pass

class UnprocessedItemError(DynamoDBError): pass



def parse_error(raw_error):
    """Parse the error we get out of Boto into something we can code around"""
    if isinstance(raw_error, Error):
        return raw_error

    error_data = json.loads(raw_error.data)
    if 'ProvisionedThroughputExceededException' in error_data['__type']:
        return ProvisionedThroughputError(error_data['message'])
    else:
        return DynamoDBError(error_data['message'], error_data['__type'])


__all__ = ["Error", "SyncUnallowedError", "DuplicateBatchItemError", "DynamoDBError", "ProvisionedThroughputError", "ItemNotFoundError"]

import json


class Error(Exception):
    """This is an ambiguous error that occured."""
    pass

class SyncUnallowedError(Error): pass

class DuplicateBatchItemError(Error): pass

class IncompleteSolventError(Error): pass

class ExceededBatchRequestsError(Error): pass

class ItemNotFoundError(Error): pass

class DynamoDBError(Error): pass

class ProvisionedThroughputError(DynamoDBError): pass

class UnprocessedItemError(DynamoDBError): pass



def parse_error(raw_error):
    """Parse the error we get out of Boto into something we can code around"""
    if isinstance(raw_error, Error):
        return raw_error

    if 'ProvisionedThroughputExceededException' in raw_error.error_code:
        return ProvisionedThroughputError(raw_error.error_message)
    else:
        return DynamoDBError(raw_error.error_message, raw_error.error_code)


__all__ = ["Error", "SyncUnallowedError", "DuplicateBatchItemError", "DynamoDBError", "ProvisionedThroughputError", "ItemNotFoundError"]

Handle updated boto exception format.
Handle updated boto exception format.

See https://github.com/boto/boto/issues/625

  import json
  
  
  class Error(Exception):
      """This is an ambiguous error that occured."""
      pass
  
  class SyncUnallowedError(Error): pass
  
  class DuplicateBatchItemError(Error): pass
  
  class IncompleteSolventError(Error): pass
  
  class ExceededBatchRequestsError(Error): pass
  
  class ItemNotFoundError(Error): pass
  
  class DynamoDBError(Error): pass
  
  class ProvisionedThroughputError(DynamoDBError): pass
  
  class UnprocessedItemError(DynamoDBError): pass
  
  
  
  def parse_error(raw_error):
      """Parse the error we get out of Boto into something we can code around"""
      if isinstance(raw_error, Error):
          return raw_error
  
-     error_data = json.loads(raw_error.data)
-     if 'ProvisionedThroughputExceededException' in error_data['__type']:
+     if 'ProvisionedThroughputExceededException' in raw_error.error_code:
-         return ProvisionedThroughputError(error_data['message'])
+         return ProvisionedThroughputError(raw_error.error_message)
      else:
-         return DynamoDBError(error_data['message'], error_data['__type'])
+         return DynamoDBError(raw_error.error_message, raw_error.error_code)
  
  
  __all__ = ["Error", "SyncUnallowedError", "DuplicateBatchItemError", "DynamoDBError", "ProvisionedThroughputError", "ItemNotFoundError"]
  
Handle updated boto exception format.
## Code Before:
import json


class Error(Exception):
    """This is an ambiguous error that occured."""
    pass

class SyncUnallowedError(Error): pass

class DuplicateBatchItemError(Error): pass

class IncompleteSolventError(Error): pass

class ExceededBatchRequestsError(Error): pass

class ItemNotFoundError(Error): pass

class DynamoDBError(Error): pass

class ProvisionedThroughputError(DynamoDBError): pass

class UnprocessedItemError(DynamoDBError): pass



def parse_error(raw_error):
    """Parse the error we get out of Boto into something we can code around"""
    if isinstance(raw_error, Error):
        return raw_error

    error_data = json.loads(raw_error.data)
    if 'ProvisionedThroughputExceededException' in error_data['__type']:
        return ProvisionedThroughputError(error_data['message'])
    else:
        return DynamoDBError(error_data['message'], error_data['__type'])


__all__ = ["Error", "SyncUnallowedError", "DuplicateBatchItemError", "DynamoDBError", "ProvisionedThroughputError", "ItemNotFoundError"]

## Instruction:
Handle updated boto exception format.
## Code After:
import json


class Error(Exception):
    """This is an ambiguous error that occured."""
    pass

class SyncUnallowedError(Error): pass

class DuplicateBatchItemError(Error): pass

class IncompleteSolventError(Error): pass

class ExceededBatchRequestsError(Error): pass

class ItemNotFoundError(Error): pass

class DynamoDBError(Error): pass

class ProvisionedThroughputError(DynamoDBError): pass

class UnprocessedItemError(DynamoDBError): pass



def parse_error(raw_error):
    """Parse the error we get out of Boto into something we can code around"""
    if isinstance(raw_error, Error):
        return raw_error

    if 'ProvisionedThroughputExceededException' in raw_error.error_code:
        return ProvisionedThroughputError(raw_error.error_message)
    else:
        return DynamoDBError(raw_error.error_message, raw_error.error_code)


__all__ = ["Error", "SyncUnallowedError", "DuplicateBatchItemError", "DynamoDBError", "ProvisionedThroughputError", "ItemNotFoundError"]
