Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UI] Fix Error Handling #188

Merged
merged 7 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions cyclops-ui/src/components/k8s-resources/ConfigMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,21 @@ const ConfigMap = ({ name, namespace }: Props) => {
setConfigMap(res.data);
})
.catch((error) => {
console.log(error);
if (error.response === undefined) {
if (error?.response?.data) {
setError({
message: error.response.data.message || String(error),
description:
error.response.data.description ||
"Check if Cyclops backend is available on: " +
window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST,
});
} else {
setError({
message: String(error),
description:
"Check if Cyclops backend is available on: " +
window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST,
});
} else {
setError(error.response.data);
}
});
}
Expand Down
43 changes: 30 additions & 13 deletions cyclops-ui/src/components/k8s-resources/Deployment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,21 @@ const Deployment = ({ name, namespace }: Props) => {
setDeployment(res.data);
})
.catch((error) => {
console.log(error);
if (error.response === undefined) {
if (error?.response?.data) {
setError({
message: error.response.data.message || String(error),
description:
error.response.data.description ||
"Check if Cyclops backend is available on: " +
window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST,
});
} else {
setError({
message: String(error),
description:
"Check if Cyclops backend is available on: " +
window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST,
});
} else {
setError(error.response.data);
}
});
}
Expand Down Expand Up @@ -185,16 +190,21 @@ const Deployment = ({ name, namespace }: Props) => {
}
})
.catch((error) => {
console.log(error);
if (error.response === undefined) {
if (error?.response?.data) {
setError({
message: error.response.data.message || String(error),
description:
error.response.data.description ||
"Check if Cyclops backend is available on: " +
window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST,
});
} else {
setError({
message: String(error),
description:
"Check if Cyclops backend is available on: " +
window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST,
});
} else {
setError(error.response.data);
}
});
};
Expand Down Expand Up @@ -291,17 +301,24 @@ const Deployment = ({ name, namespace }: Props) => {
}
})
.catch((error) => {
console.log(error);
if (error.response === undefined) {
if (error?.response?.data) {
setError({
message:
error.response.data.message || String(error),
description:
error.response.data.description ||
"Check if Cyclops backend is available on: " +
window.__RUNTIME_CONFIG__
.REACT_APP_CYCLOPS_CTRL_HOST,
});
} else {
setError({
message: String(error),
description:
"Check if Cyclops backend is available on: " +
window.__RUNTIME_CONFIG__
.REACT_APP_CYCLOPS_CTRL_HOST,
});
} else {
setError(error.response.data);
}
});
setLogsModal({
Expand All @@ -327,7 +344,7 @@ const Deployment = ({ name, namespace }: Props) => {
open={logsModal.on}
onOk={handleCancelLogs}
onCancel={handleCancelLogs}
cancelButtonProps={{ style: { display: 'none' } }}
cancelButtonProps={{ style: { display: "none" } }}
width={"60%"}
>
<Tabs items={getTabItems()} onChange={onLogsTabsChange} />
Expand Down
41 changes: 28 additions & 13 deletions cyclops-ui/src/components/k8s-resources/Pod.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,21 @@ const Pod = ({ name, namespace }: Props) => {
setPod(res.data);
})
.catch((error) => {
console.log(error);
if (error.response === undefined) {
if (error?.response?.data) {
setError({
message: error.response.data.message || String(error),
description:
error.response.data.description ||
"Check if Cyclops backend is available on: " +
window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST,
});
} else {
setError({
message: String(error),
description:
"Check if Cyclops backend is available on: " +
window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST,
});
} else {
setError(error.response.data);
}
});
}
Expand Down Expand Up @@ -206,16 +211,21 @@ const Pod = ({ name, namespace }: Props) => {
}
})
.catch((error) => {
console.log(error);
if (error.response === undefined) {
if (error?.response?.data) {
setError({
message: error.response.data.message || String(error),
description:
error.response.data.description ||
"Check if Cyclops backend is available on: " +
window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST,
});
} else {
setError({
message: String(error),
description:
"Check if Cyclops backend is available on: " +
window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST,
});
} else {
setError(error.response.data);
}
});
};
Expand Down Expand Up @@ -292,16 +302,21 @@ const Pod = ({ name, namespace }: Props) => {
}
})
.catch((error) => {
console.log(error);
if (error.response === undefined) {
if (error?.response?.data) {
setError({
message: error.response.data.message || String(error),
description:
error.response.data.description ||
"Check if Cyclops backend is available on: " +
window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST,
});
} else {
setError({
message: String(error),
description:
"Check if Cyclops backend is available on: " +
window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST,
});
} else {
setError(error.response.data);
}
});
setLogsModal({
Expand All @@ -321,7 +336,7 @@ const Pod = ({ name, namespace }: Props) => {
open={logsModal.on}
onOk={handleCancelLogs}
onCancel={handleCancelLogs}
cancelButtonProps={{ style: { display: 'none' } }}
cancelButtonProps={{ style: { display: "none" } }}
width={"60%"}
>
<Tabs items={getTabItems()} onChange={onLogsTabsChange} />
Expand Down
13 changes: 9 additions & 4 deletions cyclops-ui/src/components/k8s-resources/Service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,21 @@ const Service = ({ name, namespace }: Props) => {
setService(res.data);
})
.catch((error) => {
console.log(error);
if (error.response === undefined) {
if (error?.response?.data) {
setError({
message: error.response.data.message || String(error),
description:
error.response.data.description ||
"Check if Cyclops backend is available on: " +
window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST,
});
} else {
setError({
message: String(error),
description:
"Check if Cyclops backend is available on: " +
window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST,
});
} else {
setError(error.response.data);
}
});
}
Expand Down
43 changes: 30 additions & 13 deletions cyclops-ui/src/components/k8s-resources/StatefulSet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,21 @@ const StatefulSet = ({ name, namespace }: Props) => {
setStatefulSet(res.data);
})
.catch((error) => {
console.log(error);
if (error.response === undefined) {
if (error?.response?.data) {
setError({
message: error.response.data.message || String(error),
description:
error.response.data.description ||
"Check if Cyclops backend is available on: " +
window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST,
});
} else {
setError({
message: String(error),
description:
"Check if Cyclops backend is available on: " +
window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST,
});
} else {
setError(error.response.data);
}
});
}
Expand Down Expand Up @@ -185,16 +190,21 @@ const StatefulSet = ({ name, namespace }: Props) => {
}
})
.catch((error) => {
console.log(error);
if (error.response === undefined) {
if (error?.response?.data) {
setError({
message: error.response.data.message || String(error),
description:
error.response.data.description ||
"Check if Cyclops backend is available on: " +
window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST,
});
} else {
setError({
message: String(error),
description:
"Check if Cyclops backend is available on: " +
window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST,
});
} else {
setError(error.response.data);
}
});
};
Expand Down Expand Up @@ -291,17 +301,24 @@ const StatefulSet = ({ name, namespace }: Props) => {
}
})
.catch((error) => {
console.log(error);
if (error.response === undefined) {
if (error?.response?.data) {
setError({
message:
error.response.data.message || String(error),
description:
error.response.data.description ||
"Check if Cyclops backend is available on: " +
window.__RUNTIME_CONFIG__
.REACT_APP_CYCLOPS_CTRL_HOST,
});
} else {
setError({
message: String(error),
description:
"Check if Cyclops backend is available on: " +
window.__RUNTIME_CONFIG__
.REACT_APP_CYCLOPS_CTRL_HOST,
});
} else {
setError(error.response.data);
}
});
setLogsModal({
Expand All @@ -327,7 +344,7 @@ const StatefulSet = ({ name, namespace }: Props) => {
open={logsModal.on}
onOk={handleCancelLogs}
onCancel={handleCancelLogs}
cancelButtonProps={{ style: { display: 'none' } }}
cancelButtonProps={{ style: { display: "none" } }}
width={"60%"}
>
<Tabs items={getTabItems()} onChange={onLogsTabsChange} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,33 +193,39 @@ const EditModule = () => {
})
.catch((error) => {
setLoadTemplate(true);
if (error.response === undefined) {
if (error?.response?.data) {
setError({
message: String(error),
message: error.response.data.message || String(error),
description:
error.response.data.description ||
"Check if Cyclops backend is available on: " +
window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST,
window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST,
});
} else {
setError({
message: error.message,
description: error.response.data,
message: String(error),
description:
"Check if Cyclops backend is available on: " +
window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST,
});
}
});
})
.catch((error) => {
if (error.response === undefined) {
if (error?.response?.data) {
setError({
message: String(error),
message: error.response.data.message || String(error),
description:
error.response.data.description ||
"Check if Cyclops backend is available on: " +
window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST,
window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST,
});
} else {
setError({
message: error.message,
description: error.response.data,
message: String(error),
description:
"Check if Cyclops backend is available on: " +
window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST,
});
}
});
Expand Down Expand Up @@ -307,17 +313,20 @@ const EditModule = () => {
window.location.href = "/modules/" + moduleName;
})
.catch((error) => {
if (error.response === undefined) {
if (error?.response?.data) {
setError({
message: String(error),
message: error.response.data.message || String(error),
description:
error.response.data.description ||
"Check if Cyclops backend is available on: " +
window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST,
window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST,
});
} else {
setError({
message: error.message,
description: error.response.data,
message: String(error),
description:
"Check if Cyclops backend is available on: " +
window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST,
});
}
});
Expand Down
Loading
Loading