Skip to content

Commit 0a555ed

Browse files
committed
Fix - VueDataUi universal component - Replace throws with console errors
1 parent 1f7892d commit 0a555ed

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

src/components/vue-data-ui.vue

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -114,25 +114,27 @@ const isError = computed(() => {
114114
const currentComponent = computed(() => {
115115
if (loader.value) {
116116
const normalized = async () => {
117-
const mod = await loader.value()
118-
// If they passed a component instance already
119-
if (mod && (mod.render || mod.setup)) return mod
120-
// If it's an ES module, prefer default, else the first named export
121-
const maybeDefault = mod?.default
122-
if (maybeDefault) return maybeDefault
123-
if (mod && typeof mod === 'object') {
124-
const first = Object.values(mod)[0]
125-
if (first) return first
126-
}
127-
throw new Error('[VueDataUi] Loader did not return a component.')
117+
const mod = await loader.value()
118+
if (mod && (mod.render || mod.setup)) return mod
119+
const maybeDefault = mod?.default
120+
if (maybeDefault) return maybeDefault
121+
if (mod && typeof mod === 'object') {
122+
const first = Object.values(mod)[0]
123+
if (first) return first
124+
}
125+
console.error('[VueDataUi] Loader did not return a component.');
126+
return;
128127
}
129128
return defineAsyncComponent({ loader: normalized })
130129
}
131130
132131
const use = async () => {
133132
const reg = await loadRegistry()
134133
const l = reg[component.value]
135-
if (!l) throw new Error(`Unknown component ${component.value}`)
134+
if (!l) {
135+
console.error((`Unknown component ${component.value}`));
136+
return;
137+
}
136138
const mod = await l()
137139
return mod?.default ?? mod
138140
}

0 commit comments

Comments
 (0)