Template errors are now catched (within {})

Fixed posability for there to be an empty try block
pull/6585/head
rster20002 5 years ago
parent 068405191e
commit e71ca48735

@ -388,6 +388,10 @@ export default class Block {
const block = dev && this.get_unique_name('block'); const block = dev && this.get_unique_name('block');
let init_statements = Array.from(this.variables.values()).filter(({ init }) => init !== undefined).map(({ id, init }) => {
return b`${id} = ${init}`;
});
const body = b` const body = b`
${this.chunks.declarations} ${this.chunks.declarations}
@ -395,12 +399,14 @@ export default class Block {
return b`let ${id}`; return b`let ${id}`;
})} })}
${init_statements.length > 0
? b`
try { try {
${Array.from(this.variables.values()).filter(({ init }) => init !== undefined).map(({ id, init }) => { ${init_statements}
return b`${id} = ${init}`;
})}
} catch (e) { } catch (e) {
// @handle_error(#component, e); @handle_error(@get_current_component(), e);
}`
: ''
} }
${this.chunks.init} ${this.chunks.init}

Loading…
Cancel
Save