8000 IDEA. consider using PromiseLike interface instead of Promise class · Issue #7 · snytkine/bind-rest · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

IDEA. consider using PromiseLike interface instead of Promise class #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
snytkine opened this issue Jan 31, 2021 · 0 comments
Open

Comments

@snytkine
Copy link
Owner

This means that there will not be a .catch usage anywhere. Instead, the .then will accept a second function to handle error.
This way a middleware can have 2 functions: doFilter like it does not and onError(e: any) => Promise

One benefit is that errorFormatter becomes just a middleware instead of a function that goes inside .catch at the end.
Another benefit is that a middleware may exist somewhere in the middle of promise chain and be able to recover from error.

Another benefit is ability to switch to different Promise provider like BlueBird

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant
0