-
-
Notifications
You must be signed in to change notification settings - Fork 788
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Innei <[email protected]>
- Loading branch information
Showing
11 changed files
with
118 additions
and
122 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,8 @@ import { useEffect } from 'react' | |
|
||
// import { captureException } from '@sentry/nextjs' | ||
|
||
import { NotFound404 } from '~/components/common/404' | ||
import { NormalContainer } from '~/components/layout/container/Normal' | ||
import { StyledButton } from '~/components/ui/button' | ||
import { isRequestError, pickStatusCode } from '~/lib/is-error' | ||
|
||
// eslint-disable-next-line react/display-name | ||
export default ({ error, reset }: any) => { | ||
|
@@ -16,21 +14,13 @@ export default ({ error, reset }: any) => { | |
// captureException(error) | ||
}, [error]) | ||
|
||
if (isRequestError(error) && pickStatusCode(error) === 404) { | ||
return ( | ||
<div className="flex min-h-[calc(100vh-10rem)] flex-col center"> | ||
<NotFound404 /> | ||
</div> | ||
) | ||
} | ||
|
||
return ( | ||
<NormalContainer> | ||
<div className="flex min-h-[calc(100vh-10rem)] flex-col center"> | ||
<h2 className="mb-5"> | ||
<p> | ||
服务端渲染页面时出现了错误,可能是 Next.js 服务访问 API | ||
超时。请刷新重试。 | ||
数据发生异常。请刷新重试。 | ||
</p> | ||
<p> | ||
多次出现错误请联系开发者 <a href="mailto:[email protected]">Innei</a> | ||
|
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 was deleted.
Oops, something went wrong.
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,20 @@ | ||
import type { FC } from 'react' | ||
|
||
export const BizErrorPage: FC<{ | ||
bizMessage: string | ||
status: number | ||
}> = ({ bizMessage, status }) => { | ||
return ( | ||
<div className="flex min-h-[calc(100vh-10rem)] flex-col center"> | ||
<h2 className="mb-5 flex flex-col gap-2 text-center"> | ||
<p>数据接口请求出现错误</p> | ||
<p> | ||
HTTP Status: <strong>{status}</strong> | ||
</p> | ||
<p> | ||
错误信息:<strong>{bizMessage}</strong> | ||
</p> | ||
</h2> | ||
</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
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 was deleted.
Oops, something went wrong.
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,17 @@ | ||
import type { FetchError } from 'ofetch' | ||
|
||
import { RequestError } from '@mx-space/api-client' | ||
|
||
export const getErrorMessageFromRequestError = (error: RequestError) => { | ||
if (!(error instanceof RequestError)) return (error as Error).message | ||
const fetchError = error.raw as FetchError | ||
const messagesOrMessage = fetchError.response?._data?.message | ||
const bizMessage = | ||
typeof messagesOrMessage === 'string' | ||
? messagesOrMessage | ||
: Array.isArray(messagesOrMessage) | ||
? messagesOrMessage[0] | ||
: undefined | ||
|
||
return bizMessage || fetchError.message | ||
} |
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