#Express Error handling

9 messages · Page 1 of 1 (latest)

cyan ember
#

Hello, is it possible anyone could help me with my error handling for express, I am having a hard time figuring it out exaclty. I have it implemented but I do believe it's a janky version that could be greatly improved.

long pebble
cyan ember
#

these are my current files, but i feel my error handeling isn't as concrete as it should be.\

long pebble
#

what do you feel is wrong with it?

cyan ember
#

my error aren't concise as in, for an incorrect login, i have authentication error, invalid email or password, no user found. so many errors for the same thing and im also confused on throwing errors,. all in all, i just feel that it can be way cleaner and leaner

#

@long pebble appreciate the help btw

long pebble
#

It's okay, they are all different errors though so it makes sense you would handle them differently.
I think for security reasons it might be better to return the same message 401 "invalid email or password" in the case of user not found as well (so the attacker doesn't know if they got a username that exists or not) but that's really nitpicky and 404 is also fine, depends on your application.

#

It really looks fine to me though, I'll let someone else chime in.

cyan ember
#

ok thank you, i just want to clean it all up because its confusing the hell outta me and i want to be able to generate the correct errors quickly and clean so i can move on to other things