#NEWLINE# def handle_api_error( self , http_status , http_body , response ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# error = response [ 'error' ] #NEWLINE# #UNINDENT# except ( KeyError , TypeError ) : #NEWLINE# #INDENT# raise Error ( ( 'Invalid response from API: (%d) %r ' % ( http_status , http_body ) ) , http_status , http_body ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# raise Error ( error . get ( 'message' , '' ) , http_status , http_body ) #NEWLINE# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# raise Error ( error , http_status , http_body )