#NEWLINE# def _exception_from_message( self , msg ) : #NEWLINE# #INDENT# '\n        Create a user (or generic) exception from a WAMP error message.\n\n        :param msg: A WAMP error message.\n        :type msg: instance of :class:`autobahn.wamp.message.Error`\n        ' #NEWLINE# exc = None #NEWLINE# enc_err = None #NEWLINE# if ( msg . enc_algo == message . PAYLOAD_ENC_CRYPTO_BOX ) : #NEWLINE# #INDENT# if ( not self . _keyring ) : #NEWLINE# #INDENT# log_msg = 'received encrypted payload, but no keyring active' #NEWLINE# self . log . warn ( log_msg ) #NEWLINE# enc_err = ApplicationError ( ApplicationError . ENC_NO_KEYRING_ACTIVE , log_msg , enc_algo = msg . enc_algo ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# encrypted_payload = EncryptedPayload ( msg . enc_algo , msg . enc_key , msg . enc_serializer , msg . payload ) #NEWLINE# ( decrypted_error , msg . args , msg . kwargs ) = self . _keyring . decrypt ( True , msg . error , encrypted_payload ) #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# self . log . warn ( 'failed to decrypt application payload 1: {err}' , err = e ) #NEWLINE# enc_err = ApplicationError ( ApplicationError . ENC_DECRYPT_ERROR , 'failed to decrypt application payload 1: {}' . format ( e ) , enc_algo = msg . enc_algo ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( msg . error != decrypted_error ) : #NEWLINE# #INDENT# self . log . warn ( "URI within encrypted payload ('{decrypted_error}') does not match the envelope ('{error}')" , decrypted_error = decrypted_error , error = msg . error ) #NEWLINE# enc_err = ApplicationError ( ApplicationError . ENC_TRUSTED_URI_MISMATCH , "URI within encrypted payload ('{}') does not match the envelope ('{}')" . format ( decrypted_error , msg . error ) , enc_algo = msg . enc_algo ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if enc_err : #NEWLINE# #INDENT# return enc_err #NEWLINE# #UNINDENT# if ( msg . error in self . _uri_to_ecls ) : #NEWLINE# #INDENT# ecls = self . _uri_to_ecls [ msg . error ] #NEWLINE# try : #NEWLINE# #INDENT# if msg . kwargs : #NEWLINE# #INDENT# if msg . args : #NEWLINE# #INDENT# exc = ecls ( * msg . args , ** msg . kwargs ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# exc = ecls ( ** msg . kwargs ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if msg . args : #NEWLINE# #INDENT# exc = ecls ( * msg . args ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# exc = ecls ( ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# except Exception : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# self . onUserError ( txaio . create_failure ( ) , 'While re-constructing exception' ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( not exc ) : #NEWLINE# #INDENT# if msg . kwargs : #NEWLINE# #INDENT# if msg . args : #NEWLINE# #INDENT# exc = exception . ApplicationError ( msg . error , * msg . args , ** msg . kwargs ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# exc = exception . ApplicationError ( msg . error , ** msg . kwargs ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if msg . args : #NEWLINE# #INDENT# exc = exception . ApplicationError ( msg . error , * msg . args ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# exc = exception . ApplicationError ( msg . error ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if hasattr ( exc , 'enc_algo' ) : #NEWLINE# #INDENT# exc . enc_algo = msg . enc_algo #NEWLINE# #UNINDENT# return exc