Conversation
|
Hey @asnov ! You are right in the sense that these functions should always return a Promise. Just a question though, did you get an error when using them? Because these functions are mostly async, and errors thrown inside async functions should be transformed into rejected promises automatically (as far I understood) So just wanted to make sure you run into an error instead of a rejected Promise |
|
Hi @0xsambugs , |
|
TIL! @asnov would you mind sharing how you are getting the error and not the rejected promise? I would love to reproduce it |
|
Yeah, now I don't understand myself how I got it. I'm trying to repeat it, but in vain. Probably, it was some old version of the SDK. Give me a couple more days to repeat the steps. |
By definition, a JavaScript Promise object can be in one of three states: pending , resolved , or rejected. Throwing an error is kind of fourth state which contradicts the definition and violates the handling of promise results.
So you should not throw an error inside promise, you should reject the promise.
From a practical point of view, this means that if an error occurs in one of the simultaneously executing queries, then throwing an error does not allow tracking down which specific query caused the error and does not save the results of other queries that executed successfully. So I fixed it for quotes as this issue was not allowing to use SDK correctly.