diff --git a/src/RestSharp/RestClient.cs b/src/RestSharp/RestClient.cs index ae1a97460..ead6b3553 100644 --- a/src/RestSharp/RestClient.cs +++ b/src/RestSharp/RestClient.cs @@ -673,7 +673,8 @@ IRestResponse Deserialize(IRestRequest request, IRestResponse raw) // be deserialized if (response.ErrorException == null) { - var handler = GetHandler(raw.ContentType)(); + var func = GetHandler(raw.ContentType); + var handler = func?.Invoke(); // Only continue if there is a handler defined else there is no way to deserialize the data. // This can happen when a request returns for example a 404 page instead of the requested JSON/XML resource @@ -743,4 +744,4 @@ public UrlSegmentParamsValues(Uri builderUri, string assembled) public string Resource { get; } } } -} \ No newline at end of file +}