# Buggy code
def on_setexceptionbreakpoints_request(self, py_db, request):
    """
    :param SetExceptionBreakpointsRequest request:
    """
    # : :type arguments: SetExceptionBreakpointsArguments
    arguments = request.arguments
    filters = arguments.filters
    exception_options = arguments.exceptionOptions
    self.api.remove_all_exception_breakpoints(py_db)

    # Can't set these in the DAP.
    condition = None
    expression = None
    notify_on_first_raise_only = False

    ignore_libraries = 1 if py_db.get_use_libraries_filter() else 0

    if exception_options:
        break_raised = True
        break_uncaught = True

        for option in exception_options:
            option = ExceptionOptions(**option)
            if not option.path:
                continue

            notify_on_handled_exceptions = 1 if option.breakMode == "always" else 0
            notify_on_unhandled_exceptions = (
                1 if option.breakMode in ("unhandled", "userUnhandled") else 0
            )
            exception_paths = option.path

            exception_names = []
            if len(exception_paths) == 0:
                continue

            elif len(exception_paths) == 1:
                if "Python Exceptions" in exception_paths[0]["names"]:
                    exception_names = ["BaseException"]

            else:
                path_iterator = iter(exception_paths)
                if "Python Exceptions" in next(path_iterator)["names"]:
                    for path in path_iterator:
                        for ex_name in path["names"]:
                            exception_names.append(ex_name)

            for exception_name in exception_names:
                self.api.add_python_exception_breakpoint(
                    py_db,
                    exception_name,
                    condition,
                    expression,
                    notify_on_handled_exceptions,
                    notify_on_unhandled_exceptions,
                    notify_on_first_raise_only,
                    ignore_libraries,
                )

    else:
        break_raised = "raised" in filters
        break_uncaught = "uncaught" in filters
        if break_raised or break_uncaught:
            notify_on_handled_exceptions = 1 if break_raised else 0
            notify_on_unhandled_exceptions = 1 if break_uncaught else 0
            exception = "BaseException"

            self.api.add_python_exception_breakpoint(
                py_db,
                exception,
                condition,
                expression,
                notify_on_handled_exceptions,
                notify_on_unhandled_exceptions,
                notify_on_first_raise_only,
                ignore_libraries,
            )

    if break_raised or break_uncaught:
        btype = None
        if self._options.django_debug:
            btype = "django"
        elif self._options.flask_debug:
            btype = "jinja2"

        if btype:
            self.api.add_plugins_exception_breakpoint(
                py_db, btype, "BaseException"
            )  # Note: Exception name could be anything here.

    # Note: no body required on success.
    set_breakpoints_response = pydevd_base_schema.build_response(request)
    return NetCommand(CMD_RETURN, 0, set_breakpoints_response, is_json=True)


# Traceback (ConnectionAbortedError)
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 59880)
[20/Feb/2020 20:57:16] "GET /ajax/ing/setup/json/ HTTP/1.1" 200 712
Traceback (most recent call last):
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\socketserver.py", line 650, in process_request_thread
self.finish_request(request, client_address)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\socketserver.py", line 360, in finish_request
self. RequestHandlerClass(request, client_address, self)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\socketserver.py", line 720, in __init__
self.handle()
File "[venvpath]\lib\site-packages\django\core\servers\basehttp.py", line 174, in handle
self.handle_one_request()
File "[venvpath]\lib\site-packages\django\core\servers\basehttp.py", line 182, in handle_one_request
self.raw_requestline = self.rfile.readline(65537)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\socket.py", line 589, in readinto
return self._sock.recv_into(b)
ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine
----------------------------------------

# Fixed code
def on_setexceptionbreakpoints_request(self, py_db, request):
    """
    :param SetExceptionBreakpointsRequest request:
    """
    # : :type arguments: SetExceptionBreakpointsArguments
    arguments = request.arguments
    filters = arguments.filters
    exception_options = arguments.exceptionOptions
    self.api.remove_all_exception_breakpoints(py_db)

    # Can't set these in the DAP.
    condition = None
    expression = None
    notify_on_first_raise_only = False

    ignore_libraries = 1 if py_db.get_use_libraries_filter() else 0

    if exception_options:
        break_raised = False
        break_uncaught = False

        for option in exception_options:
            option = ExceptionOptions(**option)
            if not option.path:
                continue

            # never: never breaks
            #
            # always: always breaks
            #
            # unhandled: breaks when exception unhandled
            #
            # userUnhandled: breaks if the exception is not handled by user code

            notify_on_handled_exceptions = 1 if option.breakMode == "always" else 0
            notify_on_unhandled_exceptions = (
                1 if option.breakMode in ("unhandled", "userUnhandled") else 0
            )
            exception_paths = option.path
            break_raised |= notify_on_handled_exceptions
            break_uncaught |= notify_on_unhandled_exceptions

            exception_names = []
            if len(exception_paths) == 0:
                continue

            elif len(exception_paths) == 1:
                if "Python Exceptions" in exception_paths[0]["names"]:
                    exception_names = ["BaseException"]

            else:
                path_iterator = iter(exception_paths)
                if "Python Exceptions" in next(path_iterator)["names"]:
                    for path in path_iterator:
                        for ex_name in path["names"]:
                            exception_names.append(ex_name)

            for exception_name in exception_names:
                self.api.add_python_exception_breakpoint(
                    py_db,
                    exception_name,
                    condition,
                    expression,
                    notify_on_handled_exceptions,
                    notify_on_unhandled_exceptions,
                    notify_on_first_raise_only,
                    ignore_libraries,
                )

    else:
        break_raised = "raised" in filters
        break_uncaught = "uncaught" in filters
        if break_raised or break_uncaught:
            notify_on_handled_exceptions = 1 if break_raised else 0
            notify_on_unhandled_exceptions = 1 if break_uncaught else 0
            exception = "BaseException"

            self.api.add_python_exception_breakpoint(
                py_db,
                exception,
                condition,
                expression,
                notify_on_handled_exceptions,
                notify_on_unhandled_exceptions,
                notify_on_first_raise_only,
                ignore_libraries,
            )

    if break_raised:
        btype = None
        if self._options.django_debug:
            btype = "django"
        elif self._options.flask_debug:
            btype = "jinja2"

        if btype:
            self.api.add_plugins_exception_breakpoint(
                py_db, btype, "BaseException"
            )  # Note: Exception name could be anything here.

    # Note: no body required on success.
    set_breakpoints_response = pydevd_base_schema.build_response(request)
    return NetCommand(CMD_RETURN, 0, set_breakpoints_response, is_json=True)