[dds] Handle methodNotFound errors for setLibraryDebuggable for DWDS

DWDS doesn't currently support this so the unhandled error will terminate the DAP when running under Flutter web:

https://github.com/dart-lang/webdev/issues/606

Change-Id: I14f2dbffca66244268802924e347e2d70eec30a5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248124
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
This commit is contained in:
Danny Tuppeny 2022-06-14 16:36:47 +00:00 committed by Commit Bot
parent 40e25ebad0
commit 3056251f90

View file

@ -10,6 +10,7 @@ import 'package:collection/collection.dart';
import 'package:path/path.dart' as path;
import 'package:vm_service/vm_service.dart' as vm;
import '../rpc_error_codes.dart';
import 'adapters/dart.dart';
import 'exceptions.dart';
import 'protocol_generated.dart';
@ -694,7 +695,22 @@ class IsolateManager {
final isDebuggable = libraryUri != null
? await _adapter.libraryIsDebuggable(thread, Uri.parse(libraryUri))
: false;
await service.setLibraryDebuggable(isolateId, library.id!, isDebuggable);
try {
await service.setLibraryDebuggable(
isolateId, library.id!, isDebuggable);
} on vm.RPCError catch (e) {
// DWDS does not currently support `setLibraryDebuggable` so instead of
// failing (because this code runs in a VM event handler where there's
// no incoming request to fail/reject), just log this error.
// https://github.com/dart-lang/webdev/issues/606
if (e.code == RpcErrorCodes.kMethodNotFound) {
_adapter.logger?.call(
'setLibraryDebuggable not available ($libraryUri, $e)',
);
} else {
rethrow;
}
}
}));
}