Skip to content

Commit 2cab1a5

Browse files
committed
handle crash in error handling of access keys page
1 parent 3e93f7f commit 2cab1a5

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

portal-ui/src/screens/Console/Account/Account.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ import { errorToHandler } from "api/errors";
4747
import HelpMenu from "../HelpMenu";
4848
import { ACCOUNT_TABLE_COLUMNS } from "./AccountUtils";
4949
import { useAppDispatch } from "store";
50-
import { ApiError, ServiceAccounts } from "api/consoleApi";
50+
import { ServiceAccounts } from "api/consoleApi";
5151
import {
5252
setErrorSnackMessage,
5353
setHelpName,
@@ -105,8 +105,11 @@ const Account = () => {
105105
setRecords(sortedRows);
106106
})
107107
.catch(async (res) => {
108-
const err = (await res.json()) as ApiError;
109-
dispatch(setErrorSnackMessage(errorToHandler(err)));
108+
dispatch(
109+
setErrorSnackMessage(
110+
errorToHandler(res?.error || "Error retrieving access keys"),
111+
),
112+
);
110113
setLoading(false);
111114
});
112115
}

portal-ui/src/screens/Console/Account/AddServiceAccountScreen.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import { IAM_PAGES } from "../../../common/SecureComponent/permissions";
3535
import { setErrorSnackMessage, setHelpName } from "../../../systemSlice";
3636
import { api } from "api";
3737
import { errorToHandler } from "api/errors";
38-
import { ApiError, ContentType } from "api/consoleApi";
38+
import { ContentType } from "api/consoleApi";
3939
import CodeMirrorWrapper from "../Common/FormComponents/CodeMirrorWrapper/CodeMirrorWrapper";
4040
import AddServiceAccountHelpBox from "./AddServiceAccountHelpBox";
4141
import CredentialsPrompt from "../Common/CredentialsPrompt/CredentialsPrompt";
@@ -85,8 +85,7 @@ const AddServiceAccount = () => {
8585

8686
.catch(async (res) => {
8787
setAddSending(false);
88-
const err = (await res.json()) as ApiError;
89-
dispatch(setErrorSnackMessage(errorToHandler(err)));
88+
dispatch(setErrorSnackMessage(errorToHandler(res.error)));
9089
});
9190
}
9291
}, [addSending, setAddSending, dispatch, policyJSON, accessKey, secretKey]);

0 commit comments

Comments
 (0)