Streamlining Error Handling in Routes with a General Error Boundary
00:00 Kelly, the co-worker, has come in clutch and made us a really nice abstraction for our error boundary. So now we have this general error boundary that we can use to render errors all over the place in all of our routes, because this is a pretty common thing that you're going to want in your routes. And we want it to be consistent. We want it to be easy to do.
00:19 So you have this status handlers prop that will take a status code and then you provide a function that will be called to get what the error should say. And so here we're saying 403 should say you are not authorized to look at params.sandwichid, for example.
00:38 And so, yeah, from this you can expand it to be whatever you need it to be. You can do a 404, you could do a 400, whatever. And then if it doesn't match any of those status handlers, then it'll just be a generic error. You can feel free to look at the implementation of this.
00:55 It's pretty similar to what we've actually done already. So feel free to dive into that if you would so choose to do. But yeah, it's pretty straightforward to use and I want you to apply it to a couple of the routes that we have, including this user profile route, but also on the note ID and things.
01:14 And most everything that we're doing is all 404s right now, but in the future we'll have 400s and 403s and 401s and things like that, which this abstraction will make a lot easier. So have a good time with that and we'll see you when you're done.