Skip to content

Commit 4937cd3

Browse files
authored
feat(prepareErrorMessage): treat error.data as object (#2601)
1 parent 17c8d29 commit 4937cd3

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/utils/prepareErrorMessage.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,16 @@ export function prepareErrorMessage(error: unknown) {
44
}
55

66
if (error && typeof error === 'object') {
7-
if ('data' in error && typeof error.data === 'string') {
8-
return error.data;
7+
if ('data' in error && error.data) {
8+
if (typeof error.data === 'string') {
9+
return error.data;
10+
} else if (
11+
typeof error.data === 'object' &&
12+
'message' in error.data &&
13+
typeof error.data.message === 'string'
14+
) {
15+
return error.data.message;
16+
}
917
} else if ('statusText' in error && typeof error.statusText === 'string') {
1018
return error.statusText;
1119
} else if ('message' in error && typeof error.message === 'string') {

0 commit comments

Comments
 (0)