DEV Community

[Comment from a deleted post]
Collapse
 
viki53 profile image
Corentin H. ⚡ • Edited

I don't know if I am right, I didn't test it, but I believe every first iteration of any code (including mine, obviously), can be improved. :)

 
ycmjason profile image
YCM Jason

Well, I just checked it and it says clearly on here.

developer.mozilla.org/en-US/docs/W...

The Promise returned by catch() is rejected if onRejected throws an error or returns a Promise which is itself rejected; otherwise, it is resolved.

 
ycmjason profile image
YCM Jason

I guess I wanted to do this in the Redundant promise section, but somehow forgot. And I haven't really remove any promise from that section. Thank you for telling me! I am very glad! <3

 
viki53 profile image
Corentin H. ⚡

Glad I could help! ;)

 
ycmjason profile image
YCM Jason

I have added some changes. Tell me if it looks good? :D

 
viki53 profile image
Corentin H. ⚡ • Edited

It's great! But you haven't really updated the code everywhere, so maybe you should explain why you made it this way (or simplify the rest of the code), because this behavior might not be obvious for those who don't (yet) master the art of Promise ;)

 
ycmjason profile image
YCM Jason

Have I not changed the code? I thought I changed it all?

I added some explanation on how you can resolve a promise in catch.

 
viki53 profile image
Corentin H. ⚡

I still see a lot of return new Promise() code along the first half of the article. But I guess it makes sens if you explain it later.

I just hope people won't copy & paste without reading a bit further to get the short version. :)

 
ycmjason profile image
YCM Jason

Haha, I see what you mean.

But I guess I wouldn't worry so much about it. I think my aim is for people to understand. So I will leave it this way, it is probably easier to understand.