From 53781cbf1e0b0b06a1829b929d132c2013aac8d0 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Mon, 28 Jul 2025 16:43:46 +0530 Subject: [PATCH] fix: Improve error handling in document update process (cherry picked from commit e578513eaf9a470271d11a69f151b29459fc4ff8) --- frontend/src/data/document.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/frontend/src/data/document.js b/frontend/src/data/document.js index b1d68006..80d95255 100644 --- a/frontend/src/data/document.js +++ b/frontend/src/data/document.js @@ -27,7 +27,7 @@ export function useDocument(doctype, docname) { }, onError: (err) => { triggerOnError(err) - let errorMessage = __('Error updating document') + if (err.exc_type == 'MandatoryError') { const fieldName = err.messages .map((msg) => { @@ -35,9 +35,18 @@ export function useDocument(doctype, docname) { return arr[arr.length - 1].trim() }) .join(', ') - errorMessage = __('Mandatory field error: {0}', [fieldName]) + toast.error(__('Mandatory field error: {0}', [fieldName])) + return } - toast.error(errorMessage) + + err.messages?.forEach((msg) => { + toast.error(msg) + }) + + if (err.messages?.length === 0) { + toast.error(__('An error occurred while updating the document')) + } + console.error(err) }, },