Question
JesterXL opened this issue · comments
What's the justification around the no-exceptions rule? If I want to create pure functions, there are a few functions that throw, and I need to catch to ensure the function remains pure... or just let it blow up inside a Promise which doesn't really help me get finer grained error information.
Thanks for this library, btw!
@JesterXL, (handled)exceptions are side effects, this rule helps avoid them in your code. You can return error objects instead.
If the exception is thrown somewhere in a library and you want to handle it - you can suppress eslint error with a comment.
Awesome, that's what I was hoping you'd say, thanks!
As for new
, how do I not use that without resorting to libraries or comments? I tried to figure out how to create a new Promise
without new, but... I never figured it out so just opted out with the comment.
I tried Object.create
but she just gives me a modded prototype, and eval is t3h scary:
const success = (yay) => console.log("yay:", yay);
cow = eval('new Promise(' + success + ')');
console.log("cow:", cow);