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);