Improve exception handling #710
Labels
status: help wanted
requesting help from the community
type: community enhancement
feature request not on Twilio's roadmap
Issue Summary
The SDK has very poor error/exception handling. Debugging is awfully complex, catching specific errors in business code is a pain. Some examples:
It's fine, but gets pretty annoying if you have multiple such
catch
blocks. SDK could instead offer more specific exceptions (obviously, not for every error, but at least for the most common that are usually being catched):This is a lot cleaner and doesn't rely on magic error code numbers.
Instead, we could have gotten something like this if we relied on Guzzle exceptions under the hood (while still rethrowing RestException for BC if needed):
Currently, both of these are achievable with a custom
Twilio\Http\Client
implementation (one that only returnsTwilio\Http\Response
for successful requests and throws exceptions in all other cases), but I think it's worth implementing in the SDK itself.Technical details:
The text was updated successfully, but these errors were encountered: