sendinblue / APIv3-nodejs-library

SendinBlue's API v3 Node.js Library
ISC License
101 stars 47 forks source link

Raw error dumped on error using sendTransac() - ErrorModel not used. #42

Closed Augustin82 closed 3 years ago

Augustin82 commented 5 years ago

When one follows the example at https://github.com/sendinblue/APIv3-nodejs-library/blob/master/docs/SMTPApi.md#sendTransacEmail but there is a problem with the request (such as a bad template id, for instance), then the entire error object is dumped in the console.

Apparently, the ErrorModel object is not used; see https://github.com/sendinblue/APIv3-nodejs-library/blob/master/src/api/SMTPApi.js#L655 and https://github.com/sendinblue/APIv3-nodejs-library/blob/master/src/api/SMTPApi.js#L670 which use https://github.com/sendinblue/APIv3-nodejs-library/blob/master/src/ApiClient.js#L471, where the error is simply passed as-is.

By contrast, in the PHP SDK, the conversion seems to be made correctly: https://github.com/sendinblue/APIv3-php-library/blob/master/lib/Api/SMTPApi.php#L2999.

shubhamUpadhyayInBlue commented 3 years ago

Hi @Augustin82

As far as I understand you are facing problem in printing the exact error with the status code. Here is another issue where I have given a detailed explanation https://github.com/sendinblue/APIv3-nodejs-library/issues/62#issuecomment-731707733.

Please feel free to further elaborate your query incase you find the given information inadequate.

Thanks!

Augustin82 commented 3 years ago

Hi @shubhamUpadhyayInBlue.

My issue was open 2 (!) years ago. Apparently, you have changed the API in September with version 8. We're currently using v7.2.3, which still has SMTApi instead of TransactionalEmailsApi.

I cannot at the time migrate our codebase and confirm or not that the bug is still present.

However, reading issue #62, I'm reasonably sure it is not applicable to the problem that I have described, which showed a discrpeancy in the way things were handled between the Node and PHP versions of the API.

shubhamUpadhyayInBlue commented 3 years ago

Hi @Augustin82

Apologies for the delayed response. The links provided by you no longer exist: https://github.com/sendinblue/APIv3-php-library/blob/master/lib/Api/SMTPApi.php.

Please feel free to open a support ticket if you face any issue after using our latest version.

Thanks!