Index: runtime/lib/isolate_patch.dart |
diff --git a/runtime/lib/isolate_patch.dart b/runtime/lib/isolate_patch.dart |
index 39826f656a469ed179aab3353180142ac6db3dd9..ffd2b587eec279463bff895a55f15a55265d8de1 100644 |
--- a/runtime/lib/isolate_patch.dart |
+++ b/runtime/lib/isolate_patch.dart |
@@ -256,13 +256,19 @@ patch class Isolate { |
Completer completer = new Completer<Isolate>.sync(); |
readyPort.handler = (readyMessage) { |
readyPort.close(); |
- assert(readyMessage is List); |
- assert(readyMessage.length == 2); |
- SendPort controlPort = readyMessage[0]; |
- List capabilities = readyMessage[1]; |
- completer.complete(new Isolate(controlPort, |
- pauseCapability: capabilities[0], |
- terminateCapability: capabilities[1])); |
+ if (readyMessage is String) { |
+ // We encountered an error starting the new isolate. |
+ completer.completeError(new IsolateSpawnException( |
+ "Unable to spawn child isolate:\n${readyMessage}")); |
+ } else { |
+ assert(readyMessage is List); |
Cutch
2014/08/27 18:18:43
These asserts will only trigger in checked mode. S
turnidge
2014/08/27 19:28:59
Done.
On 2014/08/27 18:18:43, Cutch wrote:
|
+ assert(readyMessage.length == 2); |
+ SendPort controlPort = readyMessage[0]; |
+ List capabilities = readyMessage[1]; |
+ completer.complete(new Isolate(controlPort, |
+ pauseCapability: capabilities[0], |
+ terminateCapability: capabilities[1])); |
+ } |
}; |
return completer.future; |
} catch (e, st) { |
@@ -284,13 +290,19 @@ patch class Isolate { |
Completer completer = new Completer<Isolate>.sync(); |
readyPort.handler = (readyMessage) { |
readyPort.close(); |
- assert(readyMessage is List); |
- assert(readyMessage.length == 2); |
- SendPort controlPort = readyMessage[0]; |
- List capabilities = readyMessage[1]; |
- completer.complete(new Isolate(controlPort, |
- pauseCapability: capabilities[0], |
- terminateCapability: capabilities[1])); |
+ if (readyMessage is String) { |
+ // We encountered an error starting the new isolate. |
+ completer.completeError(new IsolateSpawnException( |
+ "Unable to spawn child isolate:\n${readyMessage}")); |
+ } else { |
+ assert(readyMessage is List); |
+ assert(readyMessage.length == 2); |
+ SendPort controlPort = readyMessage[0]; |
+ List capabilities = readyMessage[1]; |
+ completer.complete(new Isolate(controlPort, |
Cutch
2014/08/27 18:18:43
Duplicate code from above? Perhaps you can extract
turnidge
2014/08/27 19:28:59
Extracted common code into new function spawnCommo
|
+ pauseCapability: capabilities[0], |
+ terminateCapability: capabilities[1])); |
+ } |
}; |
return completer.future; |
} catch (e, st) { |