Display error unique id #9786
Unanswered
krzysztof-cislo
asked this question in
Q&A
Replies: 1 comment 1 reply
-
you can do it this way, in your action function throw an error with your ID if (yourCondition) {
throw json({ errorCode: `GENERATED_ID_${id}` });
} then display it in your error boundary import { isRouteErrorResponse, useRouteError } from "@remix-run/react";
export function GeneralErrorBoundary() {
const error = useRouteError();
if (
isRouteErrorResponse(error) &&
error.data?.errorCode?.startsWith("GENERATED_ID")
) {
return (
<p>GENERATED ID: {error.data.errorCode.split("GENERATED_ID_")[1]} </p>
);
}
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I would like to generate unique id in handleError where the error would be logged together with this id. Next I want to display the generated id in error boundary so user can send only the id which will be used to find correct log entry.
Is it possible?
Beta Was this translation helpful? Give feedback.
All reactions