mirror of
https://github.com/open-webui/open-webui.git
synced 2026-09-22 00:31:30 +00:00
48 lines
1.2 KiB
Svelte
48 lines
1.2 KiB
Svelte
<script lang="ts">
|
|
import Info from '$lib/components/icons/Info.svelte';
|
|
|
|
export let content: unknown = '';
|
|
|
|
const getErrorMessage = (value: unknown): string => {
|
|
if (typeof value === 'string') {
|
|
return value;
|
|
}
|
|
|
|
if (typeof value === 'object' && value !== null) {
|
|
const error = 'error' in value ? value.error : null;
|
|
|
|
if (
|
|
typeof error === 'object' &&
|
|
error !== null &&
|
|
'message' in error &&
|
|
typeof error.message === 'string'
|
|
) {
|
|
return error.message;
|
|
}
|
|
|
|
if ('detail' in value && typeof value.detail === 'string') {
|
|
return value.detail;
|
|
}
|
|
|
|
if ('message' in value && typeof value.message === 'string') {
|
|
return value.message;
|
|
}
|
|
|
|
return JSON.stringify(value) ?? String(value);
|
|
}
|
|
|
|
return JSON.stringify(value) ?? String(value);
|
|
};
|
|
|
|
$: message = getErrorMessage(content) || 'Error submitting message';
|
|
</script>
|
|
|
|
<div
|
|
class="my-2 flex w-full items-start gap-3 rounded-3xl bg-black/[0.03] px-4 py-3 text-gray-500 dark:bg-white/[0.04] dark:text-gray-400"
|
|
>
|
|
<Info className="mt-0.5 size-5 shrink-0 text-gray-400 dark:text-gray-500" strokeWidth="2" />
|
|
|
|
<div class="min-w-0 break-words text-sm leading-6">
|
|
{message}
|
|
</div>
|
|
</div>
|