catchErrors.ts 416 Bytes
Newer Older
Yoon, Daeki's avatar
Yoon, Daeki committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
export const catchErrors = (error: any, dispalyError: Function) => {
  let errorMsg;
  if (error.response) {
    errorMsg = error.response.data;
    console.log("Error response:", errorMsg);
  } else if (error.request) {
    errorMsg = error.request;
    console.log("Error request:", errorMsg);
  } else {
    errorMsg = error.message;
    console.log("Error message:", errorMsg);
  }

  dispalyError(errorMsg);
};