softlayer/softlayer-api-python-client — pull request #17 by sudorandom (2013-01-30 20:44:16+00:00)
Title: More granular exceptions

This allows more fine control over which exceptions you can catch with (hopefully) less string introspection. These exceptions have both faultCode and faultString from the XML-RPC faults..

The Exception hierarchy is as follows:

* SoftLayerError
* SoftLayerAPIError
* ParseError
* NotWellFormed
* UnsupportedEncoding
* InvalidCharacter
* ServerError
* SpecViolation
* MethodNotFound
* InvalidMethodParameters
* InternalError
* ApplicationError
* RemoteSystemError
* TransportError

These exceptions are thrown in correlation to the XML-RPC spec (http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php). SL-specific errors will be thrown as SoftLayerAPIError.

Example:
```python
>>> import SoftLayer
>>> c = SoftLayer.Client()
>>> c['i do not exist'].getObject()
Traceback (most recent call last):
File "", line 1, in
File "SoftLayer/API.py", line 312, in call_handler
return self(name, *args, **kwargs)
File "SoftLayer/API.py", line 305, in __call__
return self.client(self.name, name, *args, **kwargs)
File "SoftLayer/API.py", line 269, in __call__
verbose=self.verbose)
File "SoftLayer/transport/requests_transport.py", line 43, in make_api_call
e.faultCode, e.faultString)
SoftLayer.exceptions.MethodNotFound:
```