From the course: React: Authentication

Unlock this course with a free trial

Join today to access over 24,800 courses taught by industry experts.

Catching & handling errors

Catching & handling errors - React.js Tutorial

From the course: React: Authentication

Catching & handling errors

- [Instructor] Okay, so now that we've learned a few best practices related to error handling, let's go through our application and do just a little bit of cleanup as far as handling errors. And this should be pretty straightforward, all right? All I'm going to do is I'm going to go into the server, and I'm going to change the login route so that when the user enters in a password that's incorrect, we're not just going to send the entire error back, right? This exposes unnecessary data to the client side if something goes wrong on our server, and often can inadvertently reveal things about the technologies we're using behind the scenes as I said. So one thing that we can do here is instead of sending back the error like that, we can just send back like a status code like this, and that will make it a little bit, you know, a little bit less obvious what's going on. And also at the same time, a little harder to troubleshoot, which is why you'll often see things like that in development.…

Contents