-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #73 from softeerbootcamp4th/feat/CLAP-137
feat(CLAP-137): Suspense, ErrorBoundary 구성
- Loading branch information
Showing
11 changed files
with
122 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export const customFetch = async ( | ||
url: string, | ||
options?: RequestInit, | ||
): Promise<any> => { | ||
return fetch(url, options).then((response) => { | ||
if (!response.ok) { | ||
throw new Error(`${response.status}`); | ||
} | ||
return response; | ||
}); | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { css } from "@emotion/react"; | ||
import { theme } from "@watermelon-clap/core"; | ||
|
||
export const errorContainerStyle = css` | ||
background-image: url("/images/parts/background.svg"); | ||
background-size: cover; | ||
background-position: center; | ||
${theme.flex.center} | ||
${theme.flex.column} | ||
${theme.gap.gap32} | ||
height: 100vh; | ||
`; | ||
|
||
export const errorMessageStyle = css` | ||
${theme.font.preB24} | ||
color: ${theme.color.white}; | ||
`; |
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { FallbackProps } from "react-error-boundary"; | ||
import { errorContainerStyle, errorMessageStyle } from "./Error.css"; | ||
import { Button } from "@service/common/components/Button"; | ||
import { theme } from "@watermelon-clap/core"; | ||
import { useNavigate } from "react-router-dom"; | ||
|
||
export const Error = ({ error, resetErrorBoundary }: FallbackProps) => { | ||
const navigate = useNavigate(); | ||
let errorMessage; | ||
|
||
switch (error.message) { | ||
case "403": | ||
errorMessage = "접근 금지: 이 리소스에 접근할 권한이 없습니다."; | ||
break; | ||
case "404": | ||
errorMessage = | ||
"페이지를 찾을 수 없습니다: 요청하신 리소스를 찾을 수 없습니다."; | ||
break; | ||
case "400": | ||
errorMessage = | ||
"잘못된 요청: 요청이 이해되지 않거나 필요한 매개변수가 누락되었습니다."; | ||
break; | ||
case "500": | ||
errorMessage = "서버 오류: 잠시 후 다시 시도해 주세요."; | ||
break; | ||
default: | ||
errorMessage = "예기치 못한 오류가 발생했습니다."; | ||
} | ||
|
||
const handleHomeRedirect = () => { | ||
navigate("/"); | ||
window.location.reload(); | ||
}; | ||
|
||
return ( | ||
<div role="alert" css={errorContainerStyle}> | ||
<pre css={errorMessageStyle}>{errorMessage}</pre> | ||
<div css={[theme.flex.center, theme.gap.gap24]}> | ||
<Button onClick={handleHomeRedirect}>홈으로</Button> | ||
<Button onClick={resetErrorBoundary}>다시 시도</Button> | ||
</div> | ||
</div> | ||
); | ||
}; |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export { Error } from "./Error"; |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { css } from "@emotion/react"; | ||
import { theme } from "@watermelon-clap/core"; | ||
|
||
export const loadingStyle = css` | ||
background-image: url("/images/parts/background.svg"); | ||
background-size: cover; | ||
background-position: center; | ||
${theme.flex.center} | ||
${theme.flex.column} | ||
${theme.gap.gap32} | ||
height: 100vh; | ||
color: ${theme.color.white}; | ||
`; |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { loadingStyle } from "./Loading.css"; | ||
|
||
export const Loading = () => { | ||
return <div css={loadingStyle}>loading...</div>; | ||
}; |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export { Loading } from "./Loading"; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.