Commit 852a00a1 authored by John McCutchan's avatar John McCutchan Committed by GitHub

Detect when isolate reload is barred and inform the user (#5602)

parent a651008a
...@@ -445,9 +445,18 @@ class HotRunner extends ResidentRunner { ...@@ -445,9 +445,18 @@ class HotRunner extends ResidentRunner {
} else { } else {
flutterUsage.sendEvent('hot', 'reload'); flutterUsage.sendEvent('hot', 'reload');
} }
} catch (errorMessage, st) { } catch (error, st) {
int errorCode = error['code'];
if (errorCode == Isolate.kIsolateReloadBarred) {
printError('Unable to hot reload app due to an unrecoverable error in '
'the source code. Please address the error and then '
'Use "R" to restart the app.');
flutterUsage.sendEvent('hot', 'reload-barred');
return false;
}
String errorMessage = error['message'];
reloadStatus.stop(showElapsedTime: true); reloadStatus.stop(showElapsedTime: true);
printError('Hot reload failed:\n$errorMessage\n$st'); printError('Hot reload failed:\ncode = $errorCode\nmessage = $errorMessage\n$st');
return false; return false;
} }
await _evictDirtyAssets(); await _evictDirtyAssets();
......
...@@ -749,12 +749,18 @@ class Isolate extends ServiceObjectOwner { ...@@ -749,12 +749,18 @@ class Isolate extends ServiceObjectOwner {
_upgradeCollection(map, this); _upgradeCollection(map, this);
} }
static final int kIsolateReloadBarred = 1005;
Future<Map<String, dynamic>> reloadSources() async { Future<Map<String, dynamic>> reloadSources() async {
try { try {
Map<String, dynamic> response = await invokeRpcRaw('_reloadSources'); Map<String, dynamic> response = await invokeRpcRaw('_reloadSources');
return response; return response;
} catch (e) { } on rpc.RpcException catch(e) {
return new Future<Map<String, dynamic>>.error(e.data['details']); return new Future<Map<String, dynamic>>.error(<String, dynamic>{
'code': e.code,
'message': e.message,
'data': e.data,
});
} }
} }
......
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