Passing hasCatch since it is not possible to infer whether catch block is present from the existing info fields

pull/5149/head
Irshad P I 5 years ago
parent e29718243a
commit cd3d0f63ed

@ -188,6 +188,7 @@ export default class AwaitBlockWrapper extends Wrapper {
ctx: #ctx, ctx: #ctx,
current: null, current: null,
token: null, token: null,
hasCatch: false,
pending: ${this.pending.block.name}, pending: ${this.pending.block.name},
then: ${this.then.block.name}, then: ${this.then.block.name},
catch: ${this.catch.block.name}, catch: ${this.catch.block.name},
@ -200,6 +201,12 @@ export default class AwaitBlockWrapper extends Wrapper {
let ${info} = ${info_props}; let ${info} = ${info_props};
`); `);
if (this.catch.node.start !== null) {
block.chunks.init.push(b`
${info}.hasCatch = true;
`);
}
block.chunks.init.push(b` block.chunks.init.push(b`
@handle_promise(${promise} = ${snippet}, ${info}); @handle_promise(${promise} = ${snippet}, ${info});
`); `);

@ -59,8 +59,8 @@ export function handle_promise(promise, info) {
update(info.then, 1, info.value, value); update(info.then, 1, info.value, value);
set_current_component(null); set_current_component(null);
}, error => { }, error => {
if (info.current === info.catch && info.error === undefined) { console.log(info);
// when no catch block is present if (!info.hasCatch) {
throw error; throw error;
} }
set_current_component(current_component); set_current_component(current_component);

Loading…
Cancel
Save