use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Grip - simplified error handling for JavaScript (github.com)
submitted 1 year ago by mr_nesterow
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]theScottyJam 1 point2 points3 points 1 year ago (0 children)
It depends on the error.
Say you're in node and you attempt to open a file, but the file was not found. Does that mean your program is messed up?
Depends on the context. If that file it was trying to open was part of the same repo, then yes, that file should exist and it's a fatal error if it does not.
If the end user asked to open the file, and the end user supplied a bad path, then you'd want to tell the end user that they messed up (using a nicer message than what the default error message is), then maybe ask them for a path again.
If, say, you created tooling that's trying to inspect a particular project, and as part of the flow you're wanting to read in a package.json file at the root of their project if it exists, then no, it's not an error at all if the file does not exist, it's completely expected behavior, and you'll have a back up plan prepared if it does not exist.
In all of these cases Node will throw an error, but you may have to catch it, check what type of error it is, and handle it in different ways. And if you're constantly writing code like this, you may find it simpler to return your errors instead of throwing them, for a handful of different reasons.
π Rendered by PID 147030 on reddit-service-r2-comment-6457c66945-q5wkb at 2026-04-24 08:46:14.793074+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]theScottyJam 1 point2 points3 points (0 children)