Skip to content

Commit

Permalink
+
Browse files Browse the repository at this point in the history
  • Loading branch information
lifeart committed Jan 24, 2024
1 parent bde0f21 commit a247732
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions src/utils/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -530,43 +530,42 @@ function component(
) {
try {
return _component(comp, args, fw, ctx);
} catch(e) {

} catch (e) {
if (IS_DEV_MODE) {
let ErrorOverlayClass = customElements.get('vite-error-overlay');
let errorOverlay!: Element;
// @ts-expect-error debugName may not exist
let label = `<${comp.debugName || comp.name || comp.constructor.name} ${JSON.stringify(args)} />`;
let label = `<${
// @ts-expect-error debugName may not exist
comp.debugName || comp.name || comp.constructor.name
} ${JSON.stringify(args)} />`;
// @ts-expect-error message may not exit
e.message = `${label}\n${e.message}`;
if (!ErrorOverlayClass) {
errorOverlay = api.element('pre');
// @ts-expect-error stack may not exit
errorOverlay.textContent = `${label}\n${e.stack ?? e}`;
errorOverlay.setAttribute('style', 'color:red;border:1px solid red;padding:10px;background-color:#333;')
errorOverlay.setAttribute(
'style',
'color:red;border:1px solid red;padding:10px;background-color:#333;',
);
} else {
errorOverlay = new ErrorOverlayClass(e, true);
}

return {
ctx: null,
slots: {},
index: 0,
nodes: [
errorOverlay
]
}
nodes: [errorOverlay],
};
} else {
return {
ctx: null,
slots: {},
index: 0,
nodes: [
api.text(String(e.message)),
]
}
nodes: [api.text(String(e.message))],
};
}

}
}
// hello, basic component manager
Expand Down

0 comments on commit a247732

Please sign in to comment.