def extract_exception(*args):
    """
    Extracts the exception from given arguments or from :func:`sys.exc_info`.

    :param \*args: Arguments.
    :type \*args: \*
    :return: Extracted exception.
    :rtype: tuple
    """

    cls, instance, trcback = sys.exc_info()

    exceptions = filter(lambda x: issubclass(type(x), BaseException), args)
    trcbacks = filter(lambda x: issubclass(type(x), types.TracebackType), args)

    cls, instance = (type(exceptions[0]), exceptions[0]) if exceptions else (cls, instance)
    trcback = trcbacks[0] if trcbacks else trcback

    return cls, instance, trcback