Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URL로 다락방, 모임 접근시 예외 처리 #459

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading