Skip to content

Idiomatic promise handling? #551

Closed Answered by chriskrycho
aThorp96 asked this question in Q&A
Discussion options

You must be logged in to vote

Yeah, this is an unfortunate reality of working with Promise in general: its lack of clear handling on the error case itself is really frustrating, but falls out organically from the way that .catch() was designed to interoperate with throw. I wrote up some related notes over on #430, but those don't really get at the thing you're describing here.

Ultimately, I still think a Task-like API (#25, #215) would be the "right" way to handle this, but it's not trivial to get right and neither @bmakuh nor I have had time to fully tackle that.

In the specific example you offer here, there are a couple things to notice:

  1. First, the return type from an async function must be Promise<T> in TypeScrip…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by chriskrycho
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants