def _ToChannelError(error):
 error_map = {channel_service_pb.ChannelServiceError.INVALID_CHANNEL_KEY: InvalidChannelClientIdError, channel_service_pb.ChannelServiceError.BAD_MESSAGE: InvalidMessageError}
 if (error.application_error in error_map):
  return error_map[error.application_error](error.error_detail)
 else:
  return error

def _ToChannelError ( error ) : error_map = { channel_service_pb . ChannelServiceError . INVALID_CHANNEL_KEY : InvalidChannelClientIdError , channel_service_pb . ChannelServiceError . BAD_MESSAGE : InvalidMessageError } if ( error . application_error in error_map ) : return error_map [ error . application_error ] ( error . error_detail ) else : return error
translate an application error to a channel error .