diff --git a/src/apis/services/httpMethod.ts b/src/apis/services/httpMethod.ts index 06e737f..24e8774 100644 --- a/src/apis/services/httpMethod.ts +++ b/src/apis/services/httpMethod.ts @@ -1,5 +1,6 @@ +import { AxiosError } from 'axios'; + import axiosInstance, { setAuthToken } from '@/lib/axiosInstance'; -import { handleHttpError } from '@/utils/handleHttpError'; type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE'; @@ -29,8 +30,14 @@ async function request({ return response.data; } catch (error) { - handleHttpError(error); - throw error; + if (!(error instanceof AxiosError)) { + throw new Error('오류가 발생했습니다.'); + } + + const status = error.response?.status; + const message = error.response?.data.message || error.message; + + throw new Error(JSON.stringify({ status, message })); } }