| Handles exceptions.
    | It's possible to specify an user defined exception handler,
        if not, :func:`base_exception_handler` handler will be used.
    | The decorator uses given exceptions objects
        or the default Python `Exception <http://docs.python.org/library/exceptions.html#exceptions.Exception>`_ class.

    Usage::

        @handle_exceptions(ZeroDivisionError)
        def raiseAnException(value):
            '''
            Raises a 'ZeroDivisionError' exception.
            '''

            return value / 0

            :param \*args: Arguments.
            :type \*args: \*

    :return: Object.
    :rtype: object

def handle_exceptions(*args):
    """
    | Handles exceptions.
    | It's possible to specify an user defined exception handler,
        if not, :func:`base_exception_handler` handler will be used.
    | The decorator uses given exceptions objects
        or the default Python `Exception <http://docs.python.org/library/exceptions.html#exceptions.Exception>`_ class.

    Usage::

        @handle_exceptions(ZeroDivisionError)
        def raiseAnException(value):
            '''
            Raises a 'ZeroDivisionError' exception.
            '''

            return value / 0

            :param \*args: Arguments.
            :type \*args: \*

    :return: Object.
    :rtype: object
    """

    exceptions = tuple(filter(lambda x: issubclass(x, Exception),
                              filter(lambda x: isinstance(x, (type, types.ClassType)), args)))
    handlers = filter(lambda x: inspect.isfunction(x), args) or (base_exception_handler,)

    def handle_exceptions_decorator(object):
        """
        Handles exceptions.

        :param object: Object to decorate.
        :type object: object
        :return: Object.
        :rtype: object
        """

        @functools.wraps(object)
        def handle_exceptions_wrapper(*args, **kwargs):
            """
            Handles exceptions.

            :param \*args: Arguments.
            :type \*args: \*
            :param \*\*kwargs: Keywords arguments.
            :type \*\*kwargs: \*\*
            """

            _exceptions__frame__ = True

            try:
                return object(*args, **kwargs)
            except exceptions as error:
                for handler in handlers:
                    handler(error)

        return handle_exceptions_wrapper

    return handle_exceptions_decorator