From 54e1cadfc9e121bb918ea33e2f7ae9cde8ab4bb9 Mon Sep 17 00:00:00 2001 From: delta-lynx-89e8 Date: Mon, 23 Feb 2026 06:26:43 -0800 Subject: [PATCH] fix: show detailed validation error messages on client Parse field-specific errors from server response instead of showing generic "Validation error" message. Applies to both request() and upload() methods in the API client. Co-Authored-By: Claude Opus 4.6 --- client/src/api/client.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/client/src/api/client.ts b/client/src/api/client.ts index 4f1598b..33ce717 100644 --- a/client/src/api/client.ts +++ b/client/src/api/client.ts @@ -36,7 +36,14 @@ class ApiClient { if (!response.ok) { const error = await response.json().catch(() => ({ message: 'Request failed' })); - throw new ApiError(error.message || `HTTP ${response.status}`, response.status, error); + let message = error.message || `HTTP ${response.status}`; + if (error.errors && typeof error.errors === 'object') { + const details = Object.entries(error.errors) + .map(([field, msgs]) => `${field}: ${Array.isArray(msgs) ? msgs.join(', ') : msgs}`) + .join('; '); + if (details) message = details; + } + throw new ApiError(message, response.status, error); } return response.json(); @@ -75,7 +82,14 @@ class ApiClient { if (!response.ok) { const error = await response.json().catch(() => ({ message: 'Upload failed' })); - throw new Error(error.message || `HTTP ${response.status}`); + let message = error.message || `HTTP ${response.status}`; + if (error.errors && typeof error.errors === 'object') { + const details = Object.entries(error.errors) + .map(([field, msgs]) => `${field}: ${Array.isArray(msgs) ? msgs.join(', ') : msgs}`) + .join('; '); + if (details) message = details; + } + throw new ApiError(message, response.status, error); } return response.json();