/// <summary> /// Check whether this CRM response represents a CRM error, and if it does /// throw it as an exception. /// </summary> /// <param name="jsonResponse">A response from CRM.</param> /// <param name="payload">The payload of the request which gave rise to this response.</param> /// <exception cref="CrmServerErrorException">if the response was recognised as an error.</exception> private void CheckForCrmError(string jsonResponse, string payload) { ErrorValue error; try { error = DeserializeJson <ErrorValue>(jsonResponse); } catch (JsonSerializationException) { // it wasn't recognisable as an error. That's fine! error = new ErrorValue(); } if (error != null && error.IsPopulated()) { switch (Int32.Parse(error.number)) { case 10: case 1008: case 1009: throw new BadCredentialsException(error); default: throw new CrmServerErrorException(error, HttpUtility.UrlDecode(payload)); } } }
/// <summary> /// Check whether this CRM response represents a CRM error, and if it does /// throw it as an exception. /// </summary> /// <param name="jsonResponse">A response from CRM.</param> /// <exception cref="CrmServerErrorException">if the response was recognised as an error.</exception> private void CheckForCrmError(string jsonResponse) { ErrorValue error; try { error = DeserializeJson <ErrorValue>(jsonResponse); } catch (JsonSerializationException) { // it wasn't recognisable as an error. That's fine! error = new ErrorValue(); } if (error != null && error.IsPopulated()) { throw new CrmServerErrorException(error); } }