diff --git a/src/utils/prepareErrorMessage.ts b/src/utils/prepareErrorMessage.ts index fdf995db2a..2b125ae0e1 100644 --- a/src/utils/prepareErrorMessage.ts +++ b/src/utils/prepareErrorMessage.ts @@ -4,8 +4,16 @@ export function prepareErrorMessage(error: unknown) { } if (error && typeof error === 'object') { - if ('data' in error && typeof error.data === 'string') { - return error.data; + if ('data' in error && error.data) { + if (typeof error.data === 'string') { + return error.data; + } else if ( + typeof error.data === 'object' && + 'message' in error.data && + typeof error.data.message === 'string' + ) { + return error.data.message; + } } else if ('statusText' in error && typeof error.statusText === 'string') { return error.statusText; } else if ('message' in error && typeof error.message === 'string') {