#NEWLINE# def exception_handler_v20( status_code , error_content ) : #NEWLINE# #INDENT# 'Exception handler for API v2.0 client\n\n        This routine generates the appropriate\n        Neutron exception according to the contents of the\n        response body\n\n        :param status_code: HTTP error status code\n        :param error_content: deserialized body of error response\n    ' #NEWLINE# error_dict = None #NEWLINE# if isinstance ( error_content , dict ) : #NEWLINE# #INDENT# error_dict = error_content . get ( 'NeutronError' ) #NEWLINE# #UNINDENT# bad_neutron_error_flag = False #NEWLINE# if error_dict : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# error_type = error_dict [ 'type' ] #NEWLINE# error_message = error_dict [ 'message' ] #NEWLINE# if error_dict [ 'detail' ] : #NEWLINE# #INDENT# error_message += ( '\n' + error_dict [ 'detail' ] ) #NEWLINE# #UNINDENT# #UNINDENT# except Exception : #NEWLINE# #INDENT# bad_neutron_error_flag = True #NEWLINE# #UNINDENT# if ( not bad_neutron_error_flag ) : #NEWLINE# #INDENT# client_exc = getattr ( exceptions , ( '%sClient' % error_type ) , None ) #NEWLINE# if ( not client_exc ) : #NEWLINE# #INDENT# client_exc = exceptions . HTTP_EXCEPTION_MAP . get ( status_code ) #NEWLINE# #UNINDENT# if client_exc : #NEWLINE# #INDENT# raise client_exc ( message = error_message , status_code = status_code ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise exceptions . NeutronClientException ( status_code = status_code , message = error_message ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# raise exceptions . NeutronClientException ( status_code = status_code , message = error_dict ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# message = None #NEWLINE# if isinstance ( error_content , dict ) : #NEWLINE# #INDENT# message = error_content . get ( 'message' ) #NEWLINE# #UNINDENT# if message : #NEWLINE# #INDENT# raise exceptions . NeutronClientException ( status_code = status_code , message = message ) #NEWLINE# #UNINDENT# #UNINDENT# msg = ( '%s-%s' % ( status_code , error_content ) ) #NEWLINE# raise exceptions . NeutronClientException ( status_code = status_code , message = msg )