-
diff --git a/cadio-web/src/main/webapp/src/pages/cluster/hooks/useCluster.js b/cadio-web/src/main/webapp/src/pages/cluster/hooks/useCluster.js
index 78fb17cf..5f82372e 100644
--- a/cadio-web/src/main/webapp/src/pages/cluster/hooks/useCluster.js
+++ b/cadio-web/src/main/webapp/src/pages/cluster/hooks/useCluster.js
@@ -1,11 +1,11 @@
import axios from "axios";
import {useClusterDispatch, useClusterState} from "../context/clusterContext";
import {useParams} from "react-router-dom";
-import {axiosCatch} from "../../../utils/axiosUtils";
+import {useAxios} from "../../../utils/axiosUtils";
export default function useCluster() {
const routeParams = useParams();
-
+ const {errorCatch} = useAxios();
const clusterDispatcher = useClusterDispatch();
const {} = useClusterState();
@@ -31,7 +31,7 @@ export default function useCluster() {
keyspaceNames: response.data.result.keyspaceNameMap.SYSTEM,
})
}).catch((error) => {
- axiosCatch(error)
+ errorCatch(error)
}).finally(() => {
clusterDispatcher({
type: "SET_KEYSPACE_NAMES_LOADING",
@@ -58,7 +58,7 @@ export default function useCluster() {
keyspaceList: response.data.result.keyspaceList,
})
}).catch((error) => {
- axiosCatch(error)
+ errorCatch(error)
}).finally(() => {
clusterDispatcher({
type: "SET_KEYSPACE_LIST_LOADING",
diff --git a/cadio-web/src/main/webapp/src/pages/home-view.js b/cadio-web/src/main/webapp/src/pages/home-view.js
index 96f7b1b7..603e0c0b 100644
--- a/cadio-web/src/main/webapp/src/pages/home-view.js
+++ b/cadio-web/src/main/webapp/src/pages/home-view.js
@@ -6,7 +6,7 @@ import useCadio from "../commons/hooks/useCadio";
const HomeView = () => {
- const {openToast} = useCadio();
+ const {openToast, errorCatch} = useCadio();
const [clustersLoading, setClustersLoading] = useState(false);
const [clusters, setClusters] = useState([]);
@@ -25,7 +25,7 @@ const HomeView = () => {
}).then((response) => {
setClusters(response.data.result.clusters)
}).catch((error) => {
- //TODO : error catch
+ errorCatch(error)
}).finally(() => {
setClustersLoading(false)
});
diff --git a/cadio-web/src/main/webapp/src/pages/initialize-view.js b/cadio-web/src/main/webapp/src/pages/initialize-view.js
index 4d7f39a2..91856108 100644
--- a/cadio-web/src/main/webapp/src/pages/initialize-view.js
+++ b/cadio-web/src/main/webapp/src/pages/initialize-view.js
@@ -3,7 +3,7 @@ import axios from "axios";
import useCadio from "../commons/hooks/useCadio";
const InitializeView = (props) => {
- const {doBootstrap} = useCadio();
+ const {doBootstrap, errorCatch} = useCadio();
const [clusterInfo, setClusterInfo] = useState(
{
@@ -70,7 +70,7 @@ const InitializeView = (props) => {
alert("등록되었습니다.");
doBootstrap();
}).catch((error) => {
-
+ errorCatch(error);
}).finally(() => {
setSaveLoading(false);
})
diff --git a/cadio-web/src/main/webapp/src/utils/axiosUtils.ts b/cadio-web/src/main/webapp/src/utils/axiosUtils.ts
index 0f9c91fd..5b99d9fd 100644
--- a/cadio-web/src/main/webapp/src/utils/axiosUtils.ts
+++ b/cadio-web/src/main/webapp/src/utils/axiosUtils.ts
@@ -1,46 +1,8 @@
-import axios, {AxiosRequestConfig, AxiosResponse} from "axios";
+export function useAxios() {
-export function axiosCatch(error: any) {
- console.log(error);
+ // const {openToast} = useCadio();
- if (axios.isAxiosError(error)) {
- const {message} = error;
- const {method, url} = error.config as AxiosRequestConfig;
- const {status, statusText} = error.response as AxiosResponse;
- console.error(
- `[API] ${method?.toUpperCase()} ${url} | Error ${status} ${statusText} | ${message}`
- );
-
- switch (status) {
- case 400:
- alert(`${status} 잘못된 요청입니다.`);
- break;
- case 401: {
- alert(`${status} 인증 실패입니다.`);
- break;
- }
- case 403: {
- alert(`${status} 권한이 없습니다.`);
- break;
- }
- case 404: {
- alert(`${status} 찾을 수 없는 페이지입니다.`);
- break;
- }
- case 500: {
- alert(`${status} 서버 오류입니다.`);
- break;
- }
- default: {
- alert(`${status} 에러가 발생했습니다. ${error.message}`);
- }
- }
- } else if (error instanceof Error && error.name === "TimeoutError") {
- console.error(`[API] | TimeError ${error.toString()}`);
- alert(`${0} 요청 시간이 초과되었습니다.`);
- } else {
- console.error(`[API] | Error ${error.toString()}`);
- alert(`${0} 에러가 발생했습니다. ${error.toString()}`);
+ return {
}
}