-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
33 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,13 @@ | ||
import { useEffect } from 'react'; | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
import { AxiosError } from 'axios'; | ||
|
||
export const handleCallbackError = (isError: boolean, error: unknown) => { | ||
const navigate = useNavigate(); | ||
|
||
useEffect(() => { | ||
if (isError) { | ||
let errorMessage = ''; | ||
|
||
if (error instanceof AxiosError) { | ||
switch (error.response?.status) { | ||
case 409: | ||
errorMessage = '이미 진행 중인 콜백 요청이 있습니다.'; | ||
break; | ||
default: | ||
errorMessage = '데이터를 불러오는 중 오류가 발생했습니다.'; | ||
} | ||
} else { | ||
errorMessage = '데이터를 불러오는 중 오류가 발생했습니다.'; | ||
} | ||
|
||
alert(errorMessage); | ||
navigate('/call-back'); | ||
export const handleCallbackError = (error: unknown): string => { | ||
if (error instanceof AxiosError) { | ||
switch (error.response?.status) { | ||
case 409: | ||
return '이미 진행 중인 콜백 요청이 있습니다.'; | ||
default: | ||
return '데이터를 불러오는 중 오류가 발생했습니다.'; | ||
} | ||
}, [isError, error, navigate]); | ||
} | ||
return '데이터를 불러오는 중 오류가 발생했습니다.'; | ||
}; |