Skip to content
This repository was archived by the owner on Feb 1, 2025. It is now read-only.

Commit 8743f2f

Browse files
committed
Switch to .next behavior when a .thrown exception is successfully caught.
Fixes #82.
1 parent cf4e91c commit 8743f2f

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

runtime/dev.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,12 @@
124124
throw arg;
125125
}
126126

127-
context.dispatchException(arg);
127+
if (context.dispatchException(arg)) {
128+
// If the dispatched exception was caught by a catch block,
129+
// then let that catch block handle the exception normally.
130+
method = "next";
131+
arg = void 0;
132+
}
128133
}
129134

130135
state = GenStateExecuting;
@@ -249,7 +254,7 @@
249254

250255
dispatchException: function(exception) {
251256
var finallyEntries = [];
252-
var dispatched = false;
257+
var caught = false;
253258

254259
if (this.done) {
255260
throw exception;
@@ -263,18 +268,19 @@
263268
var entry = this.tryStack[i];
264269
if (entry.catchLoc) {
265270
this.next = entry.catchLoc;
266-
dispatched = true;
271+
caught = true;
267272
break;
268273
} else if (entry.finallyLoc) {
269274
finallyEntries.push(entry);
270-
dispatched = true;
271275
}
272276
}
273277

274278
while ((entry = finallyEntries.pop())) {
275279
this[entry.finallyTempVar] = this.next;
276280
this.next = entry.finallyLoc;
277281
}
282+
283+
return caught;
278284
},
279285

280286
delegateYield: function(generator, resultName, nextLoc) {

0 commit comments

Comments
 (0)