Skip to content

Commit 31b26d0

Browse files
committed
fix: whole output crash when a sub output fail
Bug reproduce: ``` put_collapse('title', [put_markdown(None), 'test']) ```
1 parent 732ead2 commit 31b26d0

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

webiojs/src/handlers/output.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class OutputHandler implements CommandHandler {
4141
try {
4242
elem = getWidgetElement(msg.spec);
4343
} catch (e) {
44-
return console.error(`Handle command error, command: ${msg}, error:${e}`);
44+
return console.error(`Handle command error: "${e}"\nCommand:\n${JSON.stringify(msg)}`);
4545
}
4646

4747
let container_elem = $(msg.spec.scope);

webiojs/src/models/output.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,12 @@ export function render_tpl(tpl: string, data: { [i: string]: any }) {
273273
let elem = parseHtml(html);
274274
for (let dom_id in placeholder2spec) {
275275
let spec = placeholder2spec[dom_id];
276-
let sub_elem = getWidgetElement(spec);
277-
elem.find(`#${dom_id}`).replaceWith(sub_elem);
276+
try{
277+
let sub_elem = getWidgetElement(spec);
278+
elem.find(`#${dom_id}`).replaceWith(sub_elem);
279+
}catch (e) {
280+
console.error('Error when render widget: \n%s', JSON.stringify(spec));
281+
}
278282
}
279283
return elem;
280284
}

0 commit comments

Comments
 (0)