Index: src/generator.js |
diff --git a/src/generator.js b/src/generator.js |
index b35744a094f29ef0acd8baf3180bdfb7234a9084..49a1ed266cf173c9fe78a08ba058ad0015006cb3 100644 |
--- a/src/generator.js |
+++ b/src/generator.js |
@@ -21,7 +21,12 @@ function GeneratorObjectNext(value) { |
} |
if (DEBUG_IS_ACTIVE) %DebugPrepareStepInIfStepping(this); |
- return %_GeneratorNext(this, value); |
+ try { |
+ return %_GeneratorNext(this, value); |
+ } catch (e) { |
+ %GeneratorClose(this); |
+ throw e; |
+ } |
} |
function GeneratorObjectThrow(exn) { |
@@ -30,7 +35,12 @@ function GeneratorObjectThrow(exn) { |
['[Generator].prototype.throw', this]); |
} |
- return %_GeneratorThrow(this, exn); |
+ try { |
+ return %_GeneratorThrow(this, exn); |
+ } catch (e) { |
rossberg
2014/11/12 11:56:27
Wait, won't this catch the very throw above?
wingo
2014/11/12 12:03:02
It could, if the generator itself doesn't catch it
|
+ %GeneratorClose(this); |
+ throw e; |
+ } |
} |
function GeneratorObjectIterator() { |