에러 코드 네이밍 변경
This commit is contained in:
@@ -7,18 +7,7 @@ export type NiceAxiosError = AxiosError<{
|
||||
data?: any;
|
||||
status?: string;
|
||||
}>;
|
||||
export type CBDCAxiosError = AxiosError<{
|
||||
errorCode?: string;
|
||||
code?: string;
|
||||
message?: string;
|
||||
data?: any;
|
||||
status?: string;
|
||||
}>;
|
||||
|
||||
export interface CBDCAxiosFallbackProps {
|
||||
error: CBDCAxiosError;
|
||||
resetErrorBoundary?: (...args: unknown[]) => void;
|
||||
}
|
||||
export interface NiceAxiosFallbackProps {
|
||||
error: NiceAxiosError;
|
||||
resetErrorBoundary?: (...args: unknown[]) => void;
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
import { QueryKey, UseInfiniteQueryOptions, UseMutationOptions, UseQueryOptions } from '@tanstack/react-query';
|
||||
import { CBDCAxiosError } from '@/shared/@types/error';
|
||||
import { NiceAxiosError } from '@/shared/@types/error';
|
||||
|
||||
export type QueryOptions<
|
||||
TQueryFnData = unknown,
|
||||
TError = CBDCAxiosError,
|
||||
TError = NiceAxiosError,
|
||||
TData = TQueryFnData,
|
||||
TQueryKey extends QueryKey = QueryKey,
|
||||
> = Omit<UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, 'queryKey' | 'queryFn' | 'initialData'>;
|
||||
|
||||
export type MutationOptions<TVariables = unknown, TError = CBDCAxiosError, TData = void, TContext = unknown> = Omit<
|
||||
export type MutationOptions<TVariables = unknown, TError = NiceAxiosError, TData = void, TContext = unknown> = Omit<
|
||||
UseMutationOptions<TData, TError, TVariables, TContext>,
|
||||
'mutationKey' | 'mutationFn'
|
||||
>;
|
||||
|
||||
export type InfiniteQueryOptions<
|
||||
TQueryFnData = unknown,
|
||||
TError = CBDCAxiosError,
|
||||
TError = NiceAxiosError,
|
||||
TData = TQueryFnData,
|
||||
TQueryKey extends QueryKey = QueryKey,
|
||||
TPageParam = unknown,
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import axios from 'axios';
|
||||
import { CBDCAxiosError } from '@/shared/@types/error';
|
||||
import { NiceAxiosError } from '@/shared/@types/error';
|
||||
import { IS_MOCK_PHASE } from '@/shared/constants/environment';
|
||||
|
||||
// CBDCAxiosError가 아니라면 상위 Error Boundary로 위임
|
||||
export const checkIsAxiosError = (error: Error): error is CBDCAxiosError => axios.isAxiosError(error);
|
||||
export const checkIsAxiosError = (error: Error): error is NiceAxiosError => axios.isAxiosError(error);
|
||||
|
||||
export const checkIsKickOutError = (error: CBDCAxiosError) => {
|
||||
export const checkIsKickOutError = (error: NiceAxiosError) => {
|
||||
const status = error.response?.status.toString();
|
||||
return !IS_MOCK_PHASE && (status === '401' || status === '403');
|
||||
};
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { AxiosPromise } from 'axios';
|
||||
import { CBDCAxiosError } from '@/shared/@types/error';
|
||||
import { NiceAxiosError } from '@/shared/@types/error';
|
||||
|
||||
export const resultify = async <T = any>(promiseObj: AxiosPromise<T>): Promise<T> => {
|
||||
try {
|
||||
const result: any = await promiseObj;
|
||||
return result?.data !== undefined && result?.data !== null ? result.data : result;
|
||||
} catch (error: any) {
|
||||
const axiosError = error as CBDCAxiosError;
|
||||
const axiosError = error as NiceAxiosError;
|
||||
console.error(
|
||||
`${
|
||||
axiosError.response?.status ? `[${axiosError.response.status}], ` : ''
|
||||
|
||||
Reference in New Issue
Block a user