Documentation

Exception Management

Version 1.2   |   Last Updated: 1/28/2014 (v1.2)   |  

There are a set of custom exception classes are used in the ZohoSharp library. The WebApiClientException class serves as a base class for the more detailed exception classes. It primarily defines a WebSafe property – this indicates whether, in spite of the exception, the Zoho database state may have been modified. For instance, if an exception occurs during the processing of POST results, the Zoho API has already been affected and this property should return false. Typically, however, this will return true, indicating that the Zoho database state should not have been altered.

The following types of exception classes are defined:

ApiException
An exception type that is thrown when the Zoho API responds with some form of error, exception or invalid response. ErrorCode and ErrorMessage properties are included that contain the error code and the error message provided by the Zoho API.
DeserializationException
An exception type that is thrown when a model item cannot be deserialized from the json/xml returned from the Zoho API.
ModelException
An exception type that is thrown when a strongly-typed model cannot be handled as expected.
ResponseException
An exception type that is thrown when an invalid response is received from the Zoho API.
SerializationException
An exception type that is thrown when model items cannot be serialized into xml/json for submission to the Zoho API.
ValidationException
An exception type that is thrown when a strongly-typed model cannot be validated. This class adds a ModelInstance property should be populated with a reference to the model object failing validation. It also adds a ValidationResults dictionary that represent the reason(s) for validation failure - the key is the property name and the value is a list of validation reasons. Finally, it adds a ValidationMessage property which is a formatted string representation of the ValidationResults dictionary, providing all of the reasons for validation failure.