def createException(service_exception, provider_nsa):
    # nsiconnection.ServiceException (binding) -> error.NSIError

    try:
        exception_type = error.lookup(service_exception.errorId)
        variables = [ (tvp.type, tvp.value) for tvp in service_exception.variables ] if service_exception.variables else None
        ex = exception_type(service_exception.text, service_exception.nsaId or provider_nsa, service_exception.connectionId, variables)
    except __HOLE__ as e:
        log.msg('Error looking up error id: %s. Message: %s' % (service_exception.errorId, str(e)), system=LOG_SYSTEM)
        ex = error.InternalServerError(service_exception.text)

    return ex
dataset/ETHPy150Open NORDUnet/opennsa/opennsa/protocols/nsi2/helper.py/createException