From b83e741d62a66651ed31f19f2257154c0e986c8d Mon Sep 17 00:00:00 2001 From: rbgksqkr Date: Wed, 20 Nov 2024 14:04:31 +0900 Subject: [PATCH 1/7] =?UTF-8?q?refactor:=20=EB=84=A4=ED=8A=B8=EC=9B=8C?= =?UTF-8?q?=ED=81=AC=20=EC=97=90=EB=9F=AC=EC=99=80=20=EA=B4=80=EB=A6=AC?= =?UTF-8?q?=EB=90=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EC=97=90=EB=9F=AC=20?= =?UTF-8?q?=EB=B6=84=EA=B8=B0=20=EC=B2=98=EB=A6=AC=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?#407?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/apis/fetcher.ts | 8 ++++++-- frontend/src/utils/error.ts | 5 +++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/frontend/src/apis/fetcher.ts b/frontend/src/apis/fetcher.ts index fea16a575..9d015755f 100644 --- a/frontend/src/apis/fetcher.ts +++ b/frontend/src/apis/fetcher.ts @@ -1,4 +1,4 @@ -import { CustomError, NetworkError } from '@/utils/error'; +import { CustomError, NetworkError, UnhandledError } from '@/utils/error'; interface RequestProps { url: string; @@ -26,11 +26,15 @@ const fetcher = { return response; } catch (error) { + if (error instanceof TypeError && !navigator.onLine) { + throw new NetworkError(); + } + if (error instanceof CustomError) { throw error; } - throw new NetworkError(); + throw new UnhandledError(); } }, diff --git a/frontend/src/utils/error.ts b/frontend/src/utils/error.ts index 0f6804361..55506bace 100644 --- a/frontend/src/utils/error.ts +++ b/frontend/src/utils/error.ts @@ -23,3 +23,8 @@ export class NetworkError extends Error { status = 555; message = '네트워크가 불안정해요. 다시 시도해주세요!'; } + +export class UnhandledError extends Error { + status = 5002; + message = '예기치 못한 에러가 발생했어요. 관리자에게 문의 바랍니다.'; +} From c62e279765b70b420650e6d2a5df2a0752212a20 Mon Sep 17 00:00:00 2001 From: rbgksqkr Date: Wed, 20 Nov 2024 14:05:26 +0900 Subject: [PATCH 2/7] =?UTF-8?q?refactor:=20=EC=97=90=EB=9F=AC=20=EC=83=81?= =?UTF-8?q?=ED=83=9C=20=EC=BD=94=EB=93=9C=20=EC=83=81=EC=88=98=ED=99=94=20?= =?UTF-8?q?#407?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/constants/errorStatus.ts | 3 +++ frontend/src/utils/error.ts | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 frontend/src/constants/errorStatus.ts diff --git a/frontend/src/constants/errorStatus.ts b/frontend/src/constants/errorStatus.ts new file mode 100644 index 000000000..1202f296b --- /dev/null +++ b/frontend/src/constants/errorStatus.ts @@ -0,0 +1,3 @@ +export const SERVER_ERROR_STATUS = 500; +export const NETWORK_ERROR_STATUS = 5001; +export const UNHANDLED_ERROR_STATUS = 5002; diff --git a/frontend/src/utils/error.ts b/frontend/src/utils/error.ts index 55506bace..58c1cab35 100644 --- a/frontend/src/utils/error.ts +++ b/frontend/src/utils/error.ts @@ -1,3 +1,4 @@ +import { NETWORK_ERROR_STATUS, UNHANDLED_ERROR_STATUS } from '@/constants/errorStatus'; import { ERROR_MESSAGE } from '@/constants/message'; import { ErrorCode } from '@/types/error'; @@ -20,11 +21,11 @@ export class CustomError extends Error { } export class NetworkError extends Error { - status = 555; + status = NETWORK_ERROR_STATUS; message = '네트워크가 불안정해요. 다시 시도해주세요!'; } export class UnhandledError extends Error { - status = 5002; + status = UNHANDLED_ERROR_STATUS; message = '예기치 못한 에러가 발생했어요. 관리자에게 문의 바랍니다.'; } From fcc2e93c5df31a47f04668c0486318b9bd036e59 Mon Sep 17 00:00:00 2001 From: rbgksqkr Date: Wed, 20 Nov 2024 14:06:11 +0900 Subject: [PATCH 3/7] =?UTF-8?q?refactor:=20=EC=B2=98=EB=A6=AC=EB=90=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EC=97=90=EB=9F=AC=EB=8F=84=20?= =?UTF-8?q?=EC=97=90=EB=9F=AC=20=ED=8F=B4=EB=B0=B1=20UI=EB=A5=BC=20?= =?UTF-8?q?=EB=B3=B4=EC=97=AC=EC=A3=BC=EA=B3=A0=20sentry=EB=A1=9C=20?= =?UTF-8?q?=EC=B6=94=EC=A0=81=20#407?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/ErrorBoundary/AsyncErrorBoundary.tsx | 4 ++-- .../AsyncErrorFallback/AsyncErrorFallback.tsx | 3 +-- .../QueryClientDefaultOptionProvider.tsx | 11 +++++++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/frontend/src/components/common/ErrorBoundary/AsyncErrorBoundary.tsx b/frontend/src/components/common/ErrorBoundary/AsyncErrorBoundary.tsx index 094fcebf8..c8d8231dc 100644 --- a/frontend/src/components/common/ErrorBoundary/AsyncErrorBoundary.tsx +++ b/frontend/src/components/common/ErrorBoundary/AsyncErrorBoundary.tsx @@ -6,7 +6,7 @@ import DeferredComponent from '../DeferredComponent/DeferredComponent'; import AsyncErrorFallback from '../ErrorFallback/AsyncErrorFallback/AsyncErrorFallback'; import SpinnerErrorFallback from '../ErrorFallback/SpinnerErrorFallback/SpinnerErrorFallback'; -import { CustomError } from '@/utils/error'; +import { CustomError, UnhandledError } from '@/utils/error'; interface AsyncErrorBoundaryProps { pendingFallback?: React.ReactNode; @@ -25,7 +25,7 @@ const AsyncErrorBoundary = ({ )} onError={(error) => { - if (error instanceof CustomError) { + if (error instanceof CustomError || error instanceof UnhandledError) { withScope((scope) => { scope.setLevel('warning'); scope.setTag('api', 'internalServerError'); diff --git a/frontend/src/components/common/ErrorFallback/AsyncErrorFallback/AsyncErrorFallback.tsx b/frontend/src/components/common/ErrorFallback/AsyncErrorFallback/AsyncErrorFallback.tsx index e8f95882b..1a8b8e6bd 100644 --- a/frontend/src/components/common/ErrorFallback/AsyncErrorFallback/AsyncErrorFallback.tsx +++ b/frontend/src/components/common/ErrorFallback/AsyncErrorFallback/AsyncErrorFallback.tsx @@ -7,7 +7,6 @@ import { } from '../ErrorFallback.styled'; import ErrorDdangkong from '@/assets/images/errorDdangkong.webp'; -import { CustomError } from '@/utils/error'; interface AsyncErrorFallback { error: unknown; @@ -22,7 +21,7 @@ const AsyncErrorFallback = ({ error, resetError }: AsyncErrorFallback) => { return (
에러나서 슬픈 땅콩 -

{error instanceof CustomError && error.message}

+

{error instanceof Error && error.message}

diff --git a/frontend/src/providers/ModalProvider/ModalProvider.tsx b/frontend/src/providers/ModalProvider/ModalProvider.tsx index b7d4b1825..48d147fc6 100644 --- a/frontend/src/providers/ModalProvider/ModalProvider.tsx +++ b/frontend/src/providers/ModalProvider/ModalProvider.tsx @@ -18,7 +18,7 @@ interface Modal extends ModalProps { } interface ModalDispatchContextProps { - show: (Component: React.FC | null, props?: ModalProps) => void; + showModal: (Component: React.FC | null, props?: ModalProps) => void; close: () => void; } @@ -33,7 +33,7 @@ const ModalProvider = ({ children }: PropsWithChildren) => { onConfirm: () => {}, }); - const show = (Component: React.FC | null, props?: ModalProps) => { + const showModal = (Component: React.FC | null, props?: ModalProps) => { setModal({ Component, title: props?.title, @@ -52,7 +52,7 @@ const ModalProvider = ({ children }: PropsWithChildren) => { })); }; - const dispatch = useMemo(() => ({ show, close }), []); + const dispatch = useMemo(() => ({ showModal, close }), []); return ( diff --git a/frontend/src/providers/QueryClientDefaultOptionProvider/QueryClientDefaultOptionProvider.tsx b/frontend/src/providers/QueryClientDefaultOptionProvider/QueryClientDefaultOptionProvider.tsx index 793773a88..8a5b924ae 100644 --- a/frontend/src/providers/QueryClientDefaultOptionProvider/QueryClientDefaultOptionProvider.tsx +++ b/frontend/src/providers/QueryClientDefaultOptionProvider/QueryClientDefaultOptionProvider.tsx @@ -15,7 +15,7 @@ const isServerError = (status: number) => const QueryClientDefaultOptionProvider = ({ children }: PropsWithChildren) => { const queryClient = useQueryClient(); const { showToast } = useToast(); - const { show: showModal } = useModal(); + const { showModal } = useModal(); queryClient.setDefaultOptions({ queries: { From bdd52e9206e81a5dc04899aaee680e5053c6f0a7 Mon Sep 17 00:00:00 2001 From: rbgksqkr Date: Tue, 3 Dec 2024 17:19:05 +0900 Subject: [PATCH 7/7] =?UTF-8?q?fix:=20AsyncErrorFallback=20Error=20Type=20?= =?UTF-8?q?=EC=A1=B0=EA=B1=B4=EB=AC=B8=20=EB=AA=85=ED=99=95=ED=95=98?= =?UTF-8?q?=EA=B2=8C=20=EB=AA=85=EC=8B=9C=20#407?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ErrorFallback/AsyncErrorFallback/AsyncErrorFallback.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/common/ErrorFallback/AsyncErrorFallback/AsyncErrorFallback.tsx b/frontend/src/components/common/ErrorFallback/AsyncErrorFallback/AsyncErrorFallback.tsx index 1a8b8e6bd..b444b981e 100644 --- a/frontend/src/components/common/ErrorFallback/AsyncErrorFallback/AsyncErrorFallback.tsx +++ b/frontend/src/components/common/ErrorFallback/AsyncErrorFallback/AsyncErrorFallback.tsx @@ -7,6 +7,7 @@ import { } from '../ErrorFallback.styled'; import ErrorDdangkong from '@/assets/images/errorDdangkong.webp'; +import { CustomError, UnhandledError } from '@/utils/error'; interface AsyncErrorFallback { error: unknown; @@ -21,7 +22,9 @@ const AsyncErrorFallback = ({ error, resetError }: AsyncErrorFallback) => { return (
에러나서 슬픈 땅콩 -

{error instanceof Error && error.message}

+

+ {(error instanceof CustomError || error instanceof UnhandledError) && error.message} +