0no-co / wonka

🎩 A tiny but capable push & pull stream library for TypeScript and Flow
MIT License
709 stars 29 forks source link

toPromise doesn't reject when erroring #99

Closed baptistemanson closed 3 years ago

baptistemanson commented 3 years ago

toPromise will never reject / call catch().

It makes it impossible to handle locally errors.

try {
  await client.mutation(mutation).toPromise()
}
catch(e) {
  console.warn("error");
} 

won't work.

kitten commented 3 years ago

There's a whole thread about the decision behind the lack of error events here: https://github.com/kitten/wonka/issues/39

Basically, you can trust that at the lack of runtime errors, Wonka's streams, and hence promises derived from them, will never throw or reject.

Given that you have a snippet here for urql presumably, check out how errors are represented on results here: https://formidable.com/open-source/urql/docs/basics/errors/