4Catalyzer/found

Ignoring error in renderError

wkerswell-gresham opened this issue · 1 comments

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 commented

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.