From 6b0fc45e5d26753471c27a2ed70374aa550173c1 Mon Sep 17 00:00:00 2001 From: Pier-Jean Malandrino Date: Tue, 31 Mar 2026 11:14:33 +0200 Subject: [PATCH] Fix upload error not displayed in DocumentUpload component Wrap store.upload() calls in try-catch in both onFileSelect and onDrop so thrown errors (e.g. file too large) don't bubble up unhandled. Display store.error inline below the upload hint so users see why their upload was rejected. Co-Authored-By: Claude Opus 4.6 --- .../features/document/ui/DocumentUpload.vue | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/frontend/src/features/document/ui/DocumentUpload.vue b/frontend/src/features/document/ui/DocumentUpload.vue index f1e900b..f5e3c0b 100644 --- a/frontend/src/features/document/ui/DocumentUpload.vue +++ b/frontend/src/features/document/ui/DocumentUpload.vue @@ -18,6 +18,7 @@ {{ t('upload.drop') }} {{ t('upload.maxSize') }} + {{ store.error }} @@ -42,8 +43,13 @@ async function onFileSelect(e: Event) { const target = e.target as HTMLInputElement const file = target.files?.[0] if (file) { - const doc = await store.upload(file) - if (doc) emit('uploaded', doc.id) + try { + store.clearError() + const doc = await store.upload(file) + if (doc) emit('uploaded', doc.id) + } catch { + // error is already set in store.upload + } } target.value = '' } @@ -52,8 +58,13 @@ async function onDrop(e: DragEvent) { dragging.value = false const file = e.dataTransfer?.files?.[0] if (file && file.type === 'application/pdf') { - const doc = await store.upload(file) - if (doc) emit('uploaded', doc.id) + try { + store.clearError() + const doc = await store.upload(file) + if (doc) emit('uploaded', doc.id) + } catch { + // error is already set in store.upload + } } } @@ -103,6 +114,12 @@ async function onDrop(e: DragEvent) { color: var(--text-muted); } +.upload-error { + font-size: 13px; + color: var(--error, #e53e3e); + font-weight: 500; +} + .spinner { width: 24px; height: 24px;