chargebee / chargebee-typescript

Typescript library for the Chargebee API.
https://apidocs.chargebee.com/docs/api?lang=typescript
MIT License
22 stars 16 forks source link

Core::throwError should throw error and not an object #21

Open wodka opened 2 years ago

wodka commented 2 years ago

Currently the throwError static function will return an object and not an error.

https://github.com/chargebee/chargebee-typescript/blob/d0a0bc6173c996d654ec2dee7914b077d622104b/src/core.ts#L174

This makes it problematic in terms of using it in other error management tools like Sentry.

image

ralphstodomingo commented 2 years ago

After going through the source code, detail there is probably what you're looking for?

cb-niravjadav commented 2 years ago

@wodka, You may write wrapper callback function and try to use Sentry from there. Please let us know if this is feasible for you.

wodka commented 2 years ago

@ralph-remo it's really more about allowing other tools to use the primitives of javascript to detect errors. This is harder when using objects that are not extending Error.

@cb-niravjadav I've just created a PR #25 with a new env config option useErrorObject that would allow anyone to change the behaviour from throwing an object to throwing an error.

wodka commented 2 years ago

Further: https://github.com/chargebee/chargebee-typescript/blob/master/README.md#error-handling mentions that is should be possible to check for the param in the error.

image

That value is never set? Should this be the general area / resource?