Skip to content

Commit 3d2ce5e

Browse files
committed
fix: frontend handle missing error response in API client
1 parent d9a41f8 commit 3d2ce5e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

webapp/_webapp/src/libs/apiclient.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,13 @@ class ApiClient {
136136
} catch (error) {
137137
if (error instanceof AxiosError) {
138138
const errorData = error.response?.data;
139+
if (!errorData || typeof errorData !== "object") {
140+
const message = error.message || "Network error";
141+
if (!options?.ignoreErrorToast) {
142+
errorToast(message, "Request Failed");
143+
}
144+
throw new Error(message);
145+
}
139146
const errorPayload = fromJson(ErrorSchema, errorData);
140147
if (!options?.ignoreErrorToast) {
141148
const message = this.cleanErrorMessage(errorPayload.message);

0 commit comments

Comments
 (0)