superfaceai / one-sdk-js

1️⃣ One Node.js SDK for all the APIs you want to integrate with
https://superface.ai
MIT License
47 stars 3 forks source link

[Enhancement] Cannot identify the root cause of SdkExecutionError #286

Open jnv opened 2 years ago

jnv commented 2 years ago

When the request ends with timeout or network error, I get just a generic SdkExecutionError with the root cause buried in the message, for example: Request ended with network error: timeout.

This makes representing the error to the end user harder, for example in OneService we want to format the error into a GraphQL-compliant structure and expose the root cause to the client, so they can react accordingly.

I think what would help here is to either keep the original failure packed in the returned error, or at least pass its kind.

Relevant code:

https://github.com/superfaceai/one-sdk-js/blob/fbf5e4c2b5707c135f2b086bf2edb9e5df58ae30/src/core/events/failure/policy.ts#L119-L148