File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ import { type DmError } from "@squonk/data-manager-client";
3
3
4
4
import { type AxiosError } from "axios" ;
5
5
6
+ import { nullEmptyString } from "../text" ;
7
+
6
8
const getMessageFromResponse = < TError > ( error : AxiosError < TError > , field : keyof TError ) => {
7
9
const apiErrorData = error . response ?. data ;
8
10
return apiErrorData ?. [ field ] ;
@@ -49,6 +51,11 @@ export const getErrorMessage = (error: APIErrorResponse | AxiosError | null): st
49
51
}
50
52
}
51
53
52
- // we haven't got a message from the error
53
- return "Error: no information provided" ;
54
+ // try get an error message from the error objects, skipping "", then fallback to a generic message
55
+ return (
56
+ ( typeof error ?. response ?. data === "string" ? nullEmptyString ( error . response . data ) : null ) ??
57
+ nullEmptyString ( error ?. response ?. statusText ) ??
58
+ nullEmptyString ( error ?. message ) ??
59
+ "Error: no information provided"
60
+ ) ;
54
61
} ;
You can’t perform that action at this time.
0 commit comments