Error code in the file error.tsx
Answered
Korean bullhead posted this in #help-forum
Korean bullheadOP
I need to output the content with the request error code when an error arrives. Can I somehow inside the error.tsx file handle the error code that comes when using fetch? Or maybe there is a way to call ErrorBoundary inside the page.tsx file and pass it a custom Error component? My error.tsx file looks something like this:
Inside the Error component, a switch/case is used to display the content depending on the error code.
"use client";
import { Error } from './Error';
export default function ErrorPage (props) {
return (
<Error errorType={statusCode} />
);
};Inside the Error component, a switch/case is used to display the content depending on the error code.
Answered by Ray
error.tsx is for handling unexpected errorin your case, I think its better to create a component for that
2 Replies
@Korean bullhead I need to output the content with the request error code when an error arrives. Can I somehow inside the error.tsx file handle the error code that comes when using fetch? Or maybe there is a way to call ErrorBoundary inside the page.tsx file and pass it a custom Error component? My error.tsx file looks something like this:
"use client";
import { Error } from './Error';
export default function ErrorPage (props) {
return (
<Error errorType={statusCode} />
);
};
Inside the Error component, a switch/case is used to display the content depending on the error code.
error.tsx is for handling unexpected errorin your case, I think its better to create a component for that
Answer
Korean bullheadOP
Thanks for the reply! Ended up coming to that decision too