client-nodejs icon indicating copy to clipboard operation
client-nodejs copied to clipboard

Throwing errors and good practices

Open fpirsch opened this issue 2 years ago • 4 comments

The lib throws custom objects instead of Error objects, so we don't have the stack trace and logging can't be standardized. It is considered good practice to throw only instances of the Error class or its subclasses.

https://eslint.org/docs/latest/rules/no-throw-literal https://rules.sonarsource.com/typescript/RSPEC-3696/

Custom exceptions should extend the native Error function.

fpirsch avatar Nov 29 '23 10:11 fpirsch

Hey , we've updated error handling in the next beta version of the sdk ,as well as adding typescript support in this version. you can follow the guide here for setup and feel free to give feedback or report any issues you run into

youssef-saber-3 avatar Jan 26 '24 10:01 youssef-saber-3

22.3.1-rc3 still throws intances of custom Exception classes, not native Errors

fpirsch avatar Jan 26 '24 16:01 fpirsch

Hi @fpirsch, could you give us some examples of such errors please ?

Reivilo85k avatar Mar 12 '24 11:03 Reivilo85k

Hi @Reivilo85k I was referring to FailResponseException.js, NotFoundException.js, OAuthProviderException.js, UnauthorizedException.js

fpirsch avatar Mar 12 '24 14:03 fpirsch

Hi @fpirsch ,

Thank you for your feedback. After careful consideration, we've decided to retain our current approach to custom exceptions as it aligns with our design goals. We appreciate your understanding and continued support.

Reivilo85k avatar May 21 '24 10:05 Reivilo85k