Skip to content

Commit

Permalink
fix: URL로 다락방, 모임 접근시 예외 처리
Browse files Browse the repository at this point in the history
  • Loading branch information
cys4585 committed Aug 22, 2024
1 parent 7ff7b91 commit 6cf1b3f
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions frontend/src/queryClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { QueryCache, QueryClient } from '@tanstack/react-query';

import { ApiError } from '@_utils/customError/ApiError';
import { removeToken } from '@_utils/tokenManager';
import ROUTES from '@_constants/routes';
import GET_ROUTES from '@_common/getRoutes';

const createQueryClient = () => {
return new QueryClient({
Expand All @@ -30,9 +32,24 @@ const createQueryClient = () => {

const handleApiError = (error: Error) => {
Sentry.captureException(error);
if (error instanceof ApiError && error.status === 401) {
removeToken();
window.location.href = '/home';
console.log(error);
if (error instanceof ApiError) {
if (error.status === 401) {
removeToken();
window.location.href = ROUTES.home;
return;
}
if (
error.message === '다락방이 존재하지 않습니다.' ||
error.message === '가입한 다락방이 아닙니다.'
) {
window.location.href = ROUTES.darakbangSelectOption;
return;
}
if (error.message === '모임이 존재하지 않습니다.') {
window.location.href = GET_ROUTES.nowDarakbang.main();
return;
}
} else {
alert(error instanceof Error ? error.message : 'An error occurred');
}
Expand Down

0 comments on commit 6cf1b3f

Please sign in to comment.