def METHOD_NAME(exc_class, name, functor, *args, **kwds):
    try:
        return functor(*args, **kwds)
    except PkgcoreException as e:
        if isinstance(e, exc_class):
            raise
        raise exc_class(name, e) from e