(self, result)
return Error(result['message'])
Take a result representing an error and cast it to a specific exception if possible (use a generic mandrill.Error exception for unknown cases)
Take a result representing an error and cast it to a specific exception if possible (use a generic mandrill.Error exception for unknown cases)
Take a result representing an error and cast it to a specific exception if possible ( use a generic mandrill . Error exception for unknown cases )
def cast_error(self, result):
        '''Take a result representing an error and cast it to a specific exception if possible (use a generic mandrill.Error exception for unknown cases)'''
        if not 'status' in result or result['status'] != 'error' or not 'name' in result:
            raise Error('We received an unexpected error: %r' % result)

        if result['name'] in ERROR_MAP:
            return ERROR_MAP[result['name']](result['message'])
        return Error(result['message'])
def cast_error ( self , result ) : if not 'status' in result or result [ 'status' ] != 'error' or not 'name' in result : raise Error ( 'We received an unexpected error: %r' % result ) if result [ 'name' ] in ERROR_MAP : return ERROR_MAP [ result [ 'name' ] ] ( result [ 'message' ] ) return Error ( result [ 'message' ] )