From f003d66d35bbe2e051080476344dc8f620d29dc0 Mon Sep 17 00:00:00 2001 From: Ben Jackson Date: Sat, 3 Apr 2021 19:55:58 +0100 Subject: [PATCH] Don't crash if the custom handler can't be loaded --- python3/vimspector/debug_session.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/python3/vimspector/debug_session.py b/python3/vimspector/debug_session.py index 97257b8..deb3237 100644 --- a/python3/vimspector/debug_session.py +++ b/python3/vimspector/debug_session.py @@ -897,6 +897,7 @@ class DebugSession( object ): self._splash_screen, "Unable to start adapter" ) else: + handlers = [ self ] if 'custom_handler' in self._adapter: spec = self._adapter[ 'custom_handler' ] if isinstance( spec, dict ): @@ -905,10 +906,12 @@ class DebugSession( object ): else: module, cls = spec.rsplit( '.', 1 ) - CustomHandler = getattr( importlib.import_module( module ), cls ) - handlers = [ CustomHandler( self ), self ] - else: - handlers = [ self ] + try: + CustomHandler = getattr( importlib.import_module( module ), cls ) + handlers = [ CustomHandler( self ), self ] + except ImportError: + self._logger.exception( "Unable to load custom adapter %s", + spec ) self._connection = debug_adapter_connection.DebugAdapterConnection( handlers,