restsharp/RestSharp — pull request #376 by Naliath (2013-04-21 10:26:45+00:00)
Title: Preventing System.NullReferenceException when deserializing invalid responses

Added missing ErrorException initialization when creating RestRequest from regular request.

Modified Deserialize so that the deserialization is only preformed when the request returned successfully. This because the current implementation threw an useless error when for example the request timed out and no correct header was present to be processed. This error was not caught and even if it was it would override the source error already stored in the response object.

In addition to this, a bare object was returned even when there was nothing to deserialize (invalid request, ex. 404). The returned object should of been null.