vonage-python-sdk icon indicating copy to clipboard operation
vonage-python-sdk copied to clipboard

Ability to get the SmsError status without parsing the error message

Open QuentinFchx opened this issue 6 months ago • 2 comments

Is your feature request related to a problem? Please describe. I'm currently trying to migrate from v3 to v4. When sending a SMS, I have some specific error handling code when SMS are throttled. If I'm not mistaken, the new implementation raises a SmsError when an error is detected, but does not expose the status explicitly (on which I would like to match/case) Source https://github.com/Vonage/vonage-python-sdk/blob/a8dbf81c818093e91c2ce8619c99ad5de9b6976a/sms/src/vonage_sms/sms.py#L89C19-L89C27

Describe the solution you'd like Would it be possible to expose the status returned by the API in the SmsError class? (along with the error-text while we're at it)

Describe alternatives you've considered Parsing the error message, but it's brittle.

QuentinFchx avatar Sep 01 '25 09:09 QuentinFchx

Hi @dragonmantank,

Would you accept a PR implementing this? If so, I'm not quite familiar with the library or the coding guidelines (practices / lint / tests). What would the ideal implementation looks like? Is it OK to modify the SmsError class and add both properties to it (status / error-text)? What unit tests are expected?

QuentinFchx avatar Oct 15 '25 12:10 QuentinFchx

Hello!

I would actually like to see a specific error being raised which can be caught, reducing the need for the end user to need to parse the text. So a throttling error would raise something like an SmsThrottleException, which could have an additional parameter with the timeout value exposed.

As for unit tests, a unit test showing it being raised would be enough.

dragonmantank avatar Oct 16 '25 02:10 dragonmantank