Provide more useful error message if a non-compliant DAP tool (or user) sends bad input to DAP server (#107827)
This commit is contained in:
@@ -59,6 +59,14 @@ class DebugAdapterCommand extends FlutterCommand {
|
||||
ipv6: ipv6 ?? false,
|
||||
enableDds: enableDds,
|
||||
test: boolArgDeprecated('test'),
|
||||
onError: (Object? e) {
|
||||
globals.printError(
|
||||
'Input could not be parsed as a Debug Adapter Protocol message.\n'
|
||||
'The "flutter debug-adapter" command is intended for use by tooling '
|
||||
'that communicates using the Debug Adapter Protocol.\n\n'
|
||||
'$e',
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
await server.channel.closed;
|
||||
|
||||
@@ -28,6 +28,7 @@ class FlutterDebugAdapter extends DartDebugAdapter<FlutterLaunchRequestArguments
|
||||
bool enableDds = true,
|
||||
super.enableAuthCodes,
|
||||
super.logger,
|
||||
super.onError,
|
||||
}) : _enableDds = enableDds,
|
||||
// Always disable in the DAP layer as it's handled in the spawned
|
||||
// 'flutter' process.
|
||||
|
||||
@@ -28,6 +28,7 @@ class FlutterTestDebugAdapter extends DartDebugAdapter<FlutterLaunchRequestArgum
|
||||
bool enableDds = true,
|
||||
super.enableAuthCodes,
|
||||
super.logger,
|
||||
super.onError,
|
||||
}) : _enableDds = enableDds,
|
||||
// Always disable in the DAP layer as it's handled in the spawned
|
||||
// 'flutter' process.
|
||||
|
||||
@@ -30,21 +30,28 @@ class DapServer {
|
||||
this.enableAuthCodes = true,
|
||||
bool test = false,
|
||||
this.logger,
|
||||
void Function(Object? e)? onError,
|
||||
}) : channel = ByteStreamServerChannel(input, output, logger) {
|
||||
adapter = test
|
||||
? FlutterTestDebugAdapter(channel,
|
||||
? FlutterTestDebugAdapter(
|
||||
channel,
|
||||
fileSystem: fileSystem,
|
||||
platform: platform,
|
||||
ipv6: ipv6,
|
||||
enableDds: enableDds,
|
||||
enableAuthCodes: enableAuthCodes,
|
||||
logger: logger)
|
||||
: FlutterDebugAdapter(channel,
|
||||
logger: logger,
|
||||
onError: onError,
|
||||
)
|
||||
: FlutterDebugAdapter(
|
||||
channel,
|
||||
fileSystem: fileSystem,
|
||||
platform: platform,
|
||||
enableDds: enableDds,
|
||||
enableAuthCodes: enableAuthCodes,
|
||||
logger: logger);
|
||||
logger: logger,
|
||||
onError: onError,
|
||||
);
|
||||
}
|
||||
|
||||
final ByteStreamServerChannel channel;
|
||||
|
||||
Reference in New Issue
Block a user