From cd3d0f63edc4b5747a84beeeee48a1a03f0f3589 Mon Sep 17 00:00:00 2001 From: Irshad P I Date: Tue, 14 Jul 2020 23:51:20 +0530 Subject: [PATCH] Passing hasCatch since it is not possible to infer whether catch block is present from the existing info fields --- src/compiler/compile/render_dom/wrappers/AwaitBlock.ts | 7 +++++++ src/runtime/internal/await_block.ts | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/compiler/compile/render_dom/wrappers/AwaitBlock.ts b/src/compiler/compile/render_dom/wrappers/AwaitBlock.ts index ceb898bf79..a902947c2c 100644 --- a/src/compiler/compile/render_dom/wrappers/AwaitBlock.ts +++ b/src/compiler/compile/render_dom/wrappers/AwaitBlock.ts @@ -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}); `); diff --git a/src/runtime/internal/await_block.ts b/src/runtime/internal/await_block.ts index 170b302c8a..79af506251 100644 --- a/src/runtime/internal/await_block.ts +++ b/src/runtime/internal/await_block.ts @@ -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);