#NEWLINE# def handle_response( self , method , response ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# data = response . json ( object_hook = self . get_json_object_hook ) #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# data = None #NEWLINE# #UNINDENT# if ( response . status_code == 200 ) : #NEWLINE# #INDENT# return ApiResponse ( response , method , data ) #NEWLINE# #UNINDENT# if ( data is None ) : #NEWLINE# #INDENT# raise TwitterApiError ( 'Unable to decode JSON response.' , response = response , request_method = method ) #NEWLINE# #UNINDENT# ( error_code , error_msg ) = self . get_twitter_error_details ( data ) #NEWLINE# kwargs = { #NEWLINE# #INDENT# 'response' : response , #NEWLINE# 'request_method' : method , #NEWLINE# 'error_code' : error_code , #NEWLINE# #UNINDENT# } #NEWLINE# if ( ( response . status_code == 401 ) or ( 'Bad Authentication data' in error_msg ) ) : #NEWLINE# #INDENT# raise TwitterAuthError ( error_msg , ** data ) #NEWLINE# #UNINDENT# if ( response . status_code == 404 ) : #NEWLINE# #INDENT# raise TwitterApiError ( 'Invalid API resource.' , ** kwargs ) #NEWLINE# #UNINDENT# if ( response . status_code == 429 ) : #NEWLINE# #INDENT# raise TwitterRateLimitError ( error_msg , ** kwargs ) #NEWLINE# #UNINDENT# raise TwitterApiError ( error_msg , ** kwargs )