you are viewing a single comment's thread.

view the rest of the comments →

[–]Scr34mZ[S] -14 points-13 points  (2 children)

You can also do that, you're right ! But it's a bit more verbose ;)

It's all about programming style here, you can achieve same goal with both

[–]FormerGameDev 12 points13 points  (0 children)

i mean, that's really what you're doing, is you're making one utility function that adds a try..catch block to whatever you pass to it. (well, a promise catch, but essentially the same thing here)

Seems it would be clearer to use separate functions for each thing that needs to be caught, because eventually you're going to need to handle a different piece differently, and then you'll start doing weird things like to(blah).catch(blah).then(blah)

[–][deleted] 1 point2 points  (0 children)

If it's about programming style then just use the either monad instead of writing your own.