Unverified Commit 8d6dc620 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

fix rpc exception for real (#38575)

parent a40ab895
...@@ -1116,7 +1116,10 @@ class TerminalHandler { ...@@ -1116,7 +1116,10 @@ class TerminalHandler {
lastReceivedCommand = command; lastReceivedCommand = command;
await _commonTerminalInputHandler(command); await _commonTerminalInputHandler(command);
} catch (error, st) { } catch (error, st) {
printError('$error\n$st'); // Don't print stack traces for known error types.
if (error is! ToolExit) {
printError('$error\n$st');
}
await _cleanUp(null); await _cleanUp(null);
rethrow; rethrow;
} finally { } finally {
......
...@@ -8,6 +8,7 @@ import 'package:json_rpc_2/error_code.dart' as rpc_error_code; ...@@ -8,6 +8,7 @@ import 'package:json_rpc_2/error_code.dart' as rpc_error_code;
import 'package:json_rpc_2/json_rpc_2.dart' as rpc; import 'package:json_rpc_2/json_rpc_2.dart' as rpc;
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
import 'base/async_guard.dart';
import 'base/common.dart'; import 'base/common.dart';
import 'base/context.dart'; import 'base/context.dart';
import 'base/file_system.dart'; import 'base/file_system.dart';
...@@ -576,10 +577,14 @@ class HotRunner extends ResidentRunner { ...@@ -576,10 +577,14 @@ class HotRunner extends ResidentRunner {
if (!(await hotRunnerConfig.setupHotRestart())) { if (!(await hotRunnerConfig.setupHotRestart())) {
return OperationResult(1, 'setupHotRestart failed'); return OperationResult(1, 'setupHotRestart failed');
} }
result = await _restartFromSources( // The current implementation of the vmservice and JSON rpc may throw
// unhandled exceptions into the zone that cannot be caught with a regular
// try catch. The usage is [asyncGuard] is required to normalize the error
// handling, at least until we can refactor the underlying code.
result = await asyncGuard(() => _restartFromSources(
reason: reason, reason: reason,
benchmarkMode: benchmarkMode, benchmarkMode: benchmarkMode,
); ));
if (!result.isOk) { if (!result.isOk) {
restartEvent = 'restart-failed'; restartEvent = 'restart-failed';
} }
......
...@@ -13,7 +13,6 @@ import 'package:stream_channel/stream_channel.dart'; ...@@ -13,7 +13,6 @@ import 'package:stream_channel/stream_channel.dart';
import 'package:web_socket_channel/io.dart'; import 'package:web_socket_channel/io.dart';
import 'package:web_socket_channel/web_socket_channel.dart'; import 'package:web_socket_channel/web_socket_channel.dart';
import 'base/async_guard.dart';
import 'base/common.dart'; import 'base/common.dart';
import 'base/context.dart'; import 'base/context.dart';
import 'base/file_system.dart'; import 'base/file_system.dart';
...@@ -359,7 +358,7 @@ class VMService { ...@@ -359,7 +358,7 @@ class VMService {
Future<void> _streamListen(String streamId) async { Future<void> _streamListen(String streamId) async {
if (!_listeningFor.contains(streamId)) { if (!_listeningFor.contains(streamId)) {
_listeningFor.add(streamId); _listeningFor.add(streamId);
await asyncGuard(() => _sendRequest('streamListen', <String, dynamic>{'streamId': streamId})); await _sendRequest('streamListen', <String, dynamic>{'streamId': streamId});
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment