Loading
Current section: Provider Errors 4 exercises
solution

Handling Errors and Redirecting with GitHub Authentication

Loading solution

Transcript

00:00 So let's handle this error right here. We're going to go to our provider callback, and in here, we're going to just add a catch. That's going to be an error. This is going to be async though, so let's take that error, and then we're going to throw, wait, redirect with toast.

00:18 We're going to redirect them back to the login. We're going to give them an error, let's say type error, and I don't typically like including the error message unless I really know what it's going to be, so we're just going to say an error authenticated with the label,

00:34 and then we'll console.error the error, and that's enough to get us in a good place. So we say login with GitHub, there's an error authenticated with GitHub. There's nothing they can do about it anyway, so sorry. But yeah, then if we get rid of this,

00:50 then everything should work as it did before. So we say login with GitHub, and we successfully login, which of course we do not. But this gets us to that point. So all we did was add a catch on this authenticator, authenticate, and that will handle errors in

01:08 the event that the APIs for GitHub go down for some reason.