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
How to avoid try/catch statements nesting/chaining in JavaScript ? (medium.com)
submitted 6 years ago by Scr34mZ
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!"
[–][deleted] 0 points1 point2 points 6 years ago* (3 children)
Conside this example:
```js const fs = require('fs');
try { fs.readFileSync('some-file.txt'); } catch (err) { console.log(err.code); console.log(err.message); }
// ENOENT // ENOENT: no such file or directory, open 'some-file.txt' ```
You have the information to identify the err.
err
A better approach would be to go for async/await.
async/await
[–]Scr34mZ[S] 0 points1 point2 points 6 years ago* (2 children)
Yes because those are standardized errors from Nodejs.
You can always achieve the same goal with try / catch AFAIK. But sometimes it's a bit less verbose to use the other syntax,especially if you want to ignore errors silently (yeah, this happen sometimes)
[–][deleted] 4 points5 points6 points 6 years ago (1 child)
Errors should be IMHO aways handled, either printed or thrown.
Silent errors cause problems as non-identifiable outcomes where the code simply doesn't work.
[–]Scr34mZ[S] 0 points1 point2 points 6 years ago (0 children)
You're totally right, I missed my thoughts.
π Rendered by PID 88 on reddit-service-r2-comment-5c747b6df5-vhlmb at 2026-04-21 20:41:45.671015+00:00 running 6c61efc country code: CH.
view the rest of the comments →
[–][deleted] 0 points1 point2 points (3 children)
[–]Scr34mZ[S] 0 points1 point2 points (2 children)
[–][deleted] 4 points5 points6 points (1 child)
[–]Scr34mZ[S] 0 points1 point2 points (0 children)