fix: Improve error handling in document update process
This commit is contained in:
parent
8de2a69a99
commit
e578513eaf
@ -27,7 +27,7 @@ export function useDocument(doctype, docname) {
|
|||||||
},
|
},
|
||||||
onError: (err) => {
|
onError: (err) => {
|
||||||
triggerOnError(err)
|
triggerOnError(err)
|
||||||
let errorMessage = __('Error updating document')
|
|
||||||
if (err.exc_type == 'MandatoryError') {
|
if (err.exc_type == 'MandatoryError') {
|
||||||
const fieldName = err.messages
|
const fieldName = err.messages
|
||||||
.map((msg) => {
|
.map((msg) => {
|
||||||
@ -35,9 +35,18 @@ export function useDocument(doctype, docname) {
|
|||||||
return arr[arr.length - 1].trim()
|
return arr[arr.length - 1].trim()
|
||||||
})
|
})
|
||||||
.join(', ')
|
.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)
|
console.error(err)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user