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

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

Loading…
Cancel
Save