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

How to create a custom boundary? How to catch custom errors? #193

Open
OnkelTem opened this issue Sep 2, 2020 · 0 comments
Open

How to create a custom boundary? How to catch custom errors? #193

OnkelTem opened this issue Sep 2, 2020 · 0 comments

Comments

@OnkelTem
Copy link

OnkelTem commented Sep 2, 2020

Currently there is only one boundary - NotFoundBoundary which catches only NotFoundError errors. In my app I also need to prevent access to specific pages and for that I would like to create a custom error - e.g.AccessDeniedError and corresponding boundary as well. But I'm not sure how to do it. The original NotFoundBoundary uses NaviContext which is not exported.

import { NaviContext } from './NaviContext'

export const NotFoundBoundary: React.SFC<NotFoundBoundaryProps> = function ErrorBoundary(props: NotFoundBoundaryProps) {
  return (
    <NaviContext.Consumer>
      {context => <InnerNotFoundBoundary context={context} {...props} />}
    </NaviContext.Consumer>
  )
}

So how can one add new error types and effectively catch them?

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

1 participant