Skip to content

Commit e1a2233

Browse files
committed
[js] Fix exception handling bug
1 parent 886aa20 commit e1a2233

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/vm/js/nqp-runtime/ctx.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ class Ctx extends NQPObject {
106106
let ctx = this;
107107

108108
while (ctx) {
109+
if (ctx.$$controlHandlerOuter) {
110+
ctx = ctx.$$controlHandlerOuter;
111+
}
112+
109113
if (ctx.$$CONTROL || (ctx[handler] && (!labeled || ctx.$$label === exception.$$payload))) {
110114
exception.caught = ctx;
111115
ctx.exception = exception;
@@ -131,9 +135,6 @@ class Ctx extends NQPObject {
131135
throw ctx.unwind;
132136
}
133137
ctx = ctx.$$caller;
134-
if (ctx && ctx.$$controlHandlerOuter) {
135-
ctx = ctx.$$controlHandlerOuter;
136-
}
137138
}
138139

139140
throw exception;
@@ -148,6 +149,10 @@ class Ctx extends NQPObject {
148149
let ctx = this;
149150

150151
while (ctx) {
152+
if (ctx.$$catchHandlerOuter) {
153+
ctx = ctx.$$catchHandlerOuter;
154+
}
155+
151156
if (ctx.$$CATCH) {
152157
exception.caught = ctx;
153158
ctx.exception = exception;
@@ -169,9 +174,6 @@ class Ctx extends NQPObject {
169174
throw ctx.unwind;
170175
}
171176
ctx = ctx.$$caller;
172-
if (ctx && ctx.$$catchHandlerOuter) {
173-
ctx = ctx.$$catchHandlerOuter;
174-
}
175177
}
176178

177179
throw exception;
@@ -230,6 +232,10 @@ class Ctx extends NQPObject {
230232
let ctx = lookFrom;
231233

232234
while (ctx) {
235+
if (ctx.$$controlHandlerOuter) {
236+
ctx = ctx.$$controlHandlerOuter;
237+
}
238+
233239
//TODO - think about checking the label
234240
if (ctx[handler] || ctx.$$CONTROL) {
235241
exception.caught = ctx;
@@ -257,9 +263,6 @@ class Ctx extends NQPObject {
257263
}
258264

259265
ctx = ctx.$$outer;
260-
if (ctx && ctx.$$controlHandlerOuter) {
261-
ctx = ctx.$$controlHandlerOuter;
262-
}
263266
}
264267

265268
this.$$getHLL().get('lexical_handler_not_found_error').$$call(this, null, new NQPInt(category), new NQPInt(0));

0 commit comments

Comments
 (0)