def trap_exception(e, f, default=None):
    """ Call f(), trapping e, default to default (which might be callable) """
    try:  # pragma: no cover
        return f()
    except e:  # pragma: no cover
        if callable(default):
            return default(e)
        else:
            return default