mirror of
https://github.com/nocodb/nocodb.git
synced 2026-04-29 12:26:43 +00:00
refactor(gui): check errors is an array or not
Signed-off-by: Pranav C <pranavxc@gmail.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
export async function extractSdkResponseErrorMsg(e: Error & { response: any }) {
|
||||
if (!e || !e.response) return e.message
|
||||
let msg
|
||||
let errors: any[]
|
||||
let errors: any[] | null = null
|
||||
if (e.response.data instanceof Blob) {
|
||||
try {
|
||||
const parsedData = JSON.parse(await e.response.data.text())
|
||||
@@ -15,8 +15,8 @@ export async function extractSdkResponseErrorMsg(e: Error & { response: any }) {
|
||||
errors = e.response.data.errors
|
||||
}
|
||||
|
||||
if (errors && errors.length) {
|
||||
return errors.map((e: any) => e.message).join(', ')
|
||||
if (Array.isArray(errors) && errors.length) {
|
||||
return errors.map((e: any) => (e.instancePath ? `${e.instancePath} - ` : '') + e.message).join(', ')
|
||||
}
|
||||
|
||||
return msg || 'Some error occurred'
|
||||
|
||||
Reference in New Issue
Block a user