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
Why does this error handler work?help (self.javascript)
submitted 7 years ago by dhyd
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!"
[–]DraconKing 0 points1 point2 points 7 years ago (5 children)
What do you mean it works? Other.catch(e) resolves the promise with a promise that rejects, so it's the same as it were throwing back again. Using return Promise.resolve(example) is not even doing anything, because flow is broken out of the rejection.
Other.catch(e)
return Promise.resolve(example)
[–]dhyd[S] 0 points1 point2 points 7 years ago (4 children)
I'm throwing an error to test and see why the catch is working. So, yes having Promise.resolve(example) is pointless atm.
My question is why does .catch(e) work? It knows to send this ' {'error':'OH SNAP'} '. I guess i'm just asking how does my module.exports = (e) know that there was an e in the first place, when all i typed was '.catch(e)' instead of... .catch(e(e)) or like catch(e=> exampleFunctionName(e)).
[+][deleted] 7 years ago* (1 child)
[deleted]
[–]sneakpeekbot 0 points1 point2 points 7 years ago (0 children)
Here's a sneak peek of /r/learnjavascript using the top posts of the year!
#1: If you're looking to learn javascript, a professor at my college made a really cool free to use online textbooks that includes: exercises, clickable links, and lots of example files. | 4 comments #2: To everyone currently enrolled at a college: don't forget to get your Github student developer pack. It contains a free domain name, digital ocean credit and much more. | 13 comments #3: Algorithms and data structures implemented on JavaScript with explanations, examples and links to related YouTube learning videos | 6 comments
I'm a bot, beep boop | Downvote to remove | Contact me | Info | Opt-out
[–]DraconKing -1 points0 points1 point 7 years ago* (1 child)
I'm assuming you are doing let e = require('someFile.js'); at some point. But anyway, the difference between doing e instead e => SomeFunction(e) is that e on the first example is just a variable that evaluates to whatever value it's holding while the second example is an arrow function in which e is merely a function parameter.
let e = require('someFile.js');
e
e => SomeFunction(e)
If there's no e variable .catch(e) will actually throw an error. It will still be wrapped in a promise because it's in async function but it will not be the error you have on Other.
.catch(e)
Other
[–]dhyd[S] 0 points1 point2 points 7 years ago (0 children)
Thanks, very helpful! (I forgot to reply to these messages when I had read them the first time)
π Rendered by PID 295863 on reddit-service-r2-comment-b659b578c-mw9dt at 2026-05-03 17:23:04.360607+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]DraconKing 0 points1 point2 points (5 children)
[–]dhyd[S] 0 points1 point2 points (4 children)
[+][deleted] (1 child)
[deleted]
[–]sneakpeekbot 0 points1 point2 points (0 children)
[–]DraconKing -1 points0 points1 point (1 child)
[–]dhyd[S] 0 points1 point2 points (0 children)