Comment by rglover
5 years ago
Check out the try/catch and logging pattern I use in the linked post. I added that specifically so I could identify where errors were ocurring without having to guess.
When I get the error in the console/browser, the path to the error is included for me like "[generatePasswordResetToken.setTokenOnUser] Must pass value to $set to perform an update."
With that, I know exactly where the error is ocurring and can jump straight into debugging it.
Good grief, that pattern looks like it's effectively building a stack trace by hand. Does node not provide stack traces with errors?
It provides a stack trace but it's often unintelligible. This makes the location of the error much clearer in complex code.
Yeah, there really need to be a good reason to use catch(), and that's not it.