Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignoring error in renderError #788

Open
wkerswell-gresham opened this issue Mar 1, 2021 · 1 comment
Open

Ignoring error in renderError #788

wkerswell-gresham opened this issue Mar 1, 2021 · 1 comment

Comments

@wkerswell-gresham
Copy link

Is there a way that I can ignore one of the error statuses and return the normal route? We return partial data with a 403 when the user is requesting GQL with something in the graph they cannot access. I would like the page to still render as though there was no HTTP error.

const RouteConfig = createFarceRouter({
        ...
        renderError: ({ error }) => {
            switch (error.status) {
                case 404:
                case 500:
                    return <HttpErrorPage errorCode={error.status} />;

                case 401:
                    throw new RedirectException('/login');

               case 403:
                    // Do normal route rendering

                default:
                    return null;
            }
        }
    });

Many thanks

@taion
Copy link
Contributor

taion commented Mar 8, 2021

The renderError, &c. stuff is just syntactic sugar around passing in a single render method that's the result of createRender. You can specify just render and do whatever you want, in principle. That said, in this case, you probably need to configure your network layer to not drop the entire response as an error. See facebook/relay#1913.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants