/// <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) { eErrorValue error; try { error = DeserializeJson <eErrorValue>(jsonResponse); } catch (JsonSerializationException) { // it wasn't recognisable as an error. That's fine! error = new eErrorValue(); } if (error != null && error.IsPopulated()) { throw new CrmServerErrorException(error); } }
public CrmServerErrorException(eErrorValue error) : base($"CRM Server error {error.number} ({error.name}): {error.description}") { this.Error = error; }