case response.code.to_i
when 200, 201, 204, 401, 404, 405, 422
json = JSON.parse(response.body)
else
raise InvalidPhoneNumberException, 'Unknown response from server'
end
This is always an InvalidPhoneNumberException. It'd make more sense to have a more subtle name for this, e.g. ServerException.
Additionally, InvalidPhoneNumberException derives from TypeError: as per the docs, this is an error type that should be raised "when encountering an object that is not of the expected type".
It should be noted that this is a backwards incompatible change, and therefore requires a new major version. This is not currently planned.
A temporary backwards compatible workaround is to create a new exception type that extends the current InvalidPhoneNumberException:
class ServerException < InvalidPhoneNumberException; end
Currently, if the MessageBird API returns a unexpected HTTP status code, the client raises an error.
This is always an
InvalidPhoneNumberException
. It'd make more sense to have a more subtle name for this, e.g.ServerException
.Additionally,
InvalidPhoneNumberException
derives fromTypeError
: as per the docs, this is an error type that should be raised "when encountering an object that is not of the expected type".It should be noted that this is a backwards incompatible change, and therefore requires a new major version. This is not currently planned.
A temporary backwards compatible workaround is to create a new exception type that extends the current
InvalidPhoneNumberException
: