88import com .intellij .xdebugger .XDebuggerManager ;
99import org .jetbrains .annotations .NotNull ;
1010
11+ import java .lang .reflect .InvocationTargetException ;
1112import java .lang .reflect .Method ;
1213
1314public class FlutterDebugSessionUtils {
@@ -57,8 +58,14 @@ public static RunContentDescriptor startSessionAndGetDescriptor(
5758 session .setBreakpointMuted (true );
5859 }
5960 return session .getRunContentDescriptor ();
61+ } catch (InvocationTargetException e ) {
62+ Throwable cause = e .getCause ();
63+ if (cause instanceof ExecutionException ) {
64+ throw (ExecutionException ) cause ;
65+ }
66+ throw new ExecutionException ("Failed to start debug session via reflection" , cause != null ? cause : e );
6067 } catch (Exception e ) {
61- throw new ExecutionException ("Failed to start debug session via reflection" , e );
68+ throw new ExecutionException ("Failed with unexpected reflection error " , e );
6269 }
6370 }
6471
@@ -75,8 +82,14 @@ public static XDebugSession startSession(
7582 } catch (NoSuchMethodException e ) {
7683 // Fallback to old API
7784 return manager .startSession (env , starter );
85+ } catch (InvocationTargetException e ) {
86+ Throwable cause = e .getCause ();
87+ if (cause instanceof ExecutionException ) {
88+ throw (ExecutionException ) cause ;
89+ }
90+ throw new ExecutionException ("Failed to start debug session via reflection" , cause != null ? cause : e );
7891 } catch (Exception e ) {
79- throw new ExecutionException ("Failed to start debug session via reflection" , e );
92+ throw new ExecutionException ("Failed with unexpected reflection error " , e );
8093 }
8194 }
8295 @ NotNull
0 commit comments