Skip to content

Commit

Permalink
Fix error handling issue and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
elliette committed Aug 9, 2023
1 parent 91cbd18 commit f9b7592
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 29 deletions.
52 changes: 25 additions & 27 deletions dwds/lib/src/services/chrome_proxy_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,17 @@ ${globalLoadStrategy.loadModuleSnippet}("dart_sdk").developer.invokeExtension(
isolateId,
step: step,
frameIndex: frameIndex,
).catchError(
(error) => Future<Success>.error(
RPCError(
'resume',
RPCErrorKind.kIsolateMustBePaused.code,
error,
),
),
test: (e) => e.toString().contains(
'Can only perform operation while paused',
),
),
);

Expand All @@ -1088,33 +1099,20 @@ ${globalLoadStrategy.loadModuleSnippet}("dart_sdk").developer.invokeExtension(
String? step,
int? frameIndex,
}) async {
try {
if (inspector.appConnection.isStarted) {
return captureElapsedTime(
() async {
await isInitialized;
await isStarted;
_checkIsolate('resume', isolateId);
return await (await debuggerFuture)
.resume(step: step, frameIndex: frameIndex);
},
(result) => DwdsEvent.resume(step),
);
} else {
inspector.appConnection.runMain();
return Success();
}
} on WipError catch (e) {
final errorMessage = e.message;
if (errorMessage != null &&
errorMessage.contains('Can only perform operation while paused')) {
throw RPCError(
'resume',
RPCErrorKind.kIsolateMustBePaused.code,
errorMessage,
);
}
rethrow;
if (inspector.appConnection.isStarted) {
return captureElapsedTime(
() async {
await isInitialized;
await isStarted;
_checkIsolate('resume', isolateId);
return await (await debuggerFuture)
.resume(step: step, frameIndex: frameIndex);
},
(result) => DwdsEvent.resume(step),
);
} else {
inspector.appConnection.runMain();
return Success();
}
}

Expand Down
10 changes: 8 additions & 2 deletions dwds/test/chrome_proxy_service_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1368,12 +1368,18 @@ void main() {
expect(pauseBreakpoints, hasLength(1));
expect(pauseBreakpoints.first.id, bp.id);
await service.removeBreakpoint(isolateId!, bp.id!);
});

tearDown(() async {
// Resume execution to not impact other tests.
await service.resume(isolateId!);
});

test('resuming throws error if not paused', () async {
await expectLater(
service.resume(isolateId!),
// Note: 106 is the `kIsolateMustBePaused` error code.
throwsRPCErrorWithMessage('106'),
);
});
});

group('Step', () {
Expand Down

0 comments on commit f9b7592

Please sign in to comment.