/// <summary> /// Helper method that allows the SDK to throw the appropriate /// HealthServiceException based on the status code indicating the error /// type. /// </summary> /// /// <param name="errorCode"> /// The status code representing the error which occurred. /// </param> /// /// <param name="error"> /// Information about an error that occurred while processing /// the request. /// </param> /// internal static HealthServiceException GetHealthServiceException( HealthServiceStatusCode errorCode, HealthServiceResponseError error) { HealthServiceException e; switch (errorCode) { case HealthServiceStatusCode.CredentialTokenExpired: e = new HealthServiceCredentialTokenExpiredException(error); break; case HealthServiceStatusCode.AuthenticatedSessionTokenExpired: e = new HealthServiceAuthenticatedSessionTokenExpiredException(error); break; case HealthServiceStatusCode.InvalidPerson: e = new HealthServiceInvalidPersonException(error); break; case HealthServiceStatusCode.InvalidRecord: e = new HealthServiceInvalidRecordException(error); break; case HealthServiceStatusCode.AccessDenied: e = new HealthServiceAccessDeniedException(error); break; case HealthServiceStatusCode.InvalidApplicationAuthorization: e = new HealthServiceInvalidApplicationAuthorizationException(error); break; case HealthServiceStatusCode.DuplicateCredentialFound: e = new HealthServiceApplicationDuplicateCredentialException(error); break; case HealthServiceStatusCode.MailAddressMalformed: e = new HealthServiceMailAddressMalformedException(error); break; case HealthServiceStatusCode.PasswordNotStrong: e = new HealthServicePasswordNotStrongException(error); break; case HealthServiceStatusCode.RecordQuotaExceeded: e = new HealthServiceRecordQuotaExceededException(error); break; default: e = new HealthServiceException(errorCode, error); break; } return(e); }
/// <summary> /// Helper method that allows the SDK to throw the appropriate /// HealthServiceException based on the status code returned by /// HealthVault. /// </summary> /// /// <param name="responseData"> /// The HealthServiceResponseData object created by parsing response returned by HealthVault. /// </param> /// internal static HealthServiceException GetHealthServiceException(HealthServiceResponseData responseData) { HealthServiceStatusCode errorCode = HealthServiceStatusCodeManager.GetStatusCode(responseData.CodeId); var e = errorCode != HealthServiceStatusCode.UnmappedError ? GetHealthServiceException(errorCode, responseData.Error) : new HealthServiceException(responseData.CodeId, responseData.Error); e.Response = responseData; return(e); }
/// <summary> /// Helper factory method to help cast any integer status code /// to an appropriate HealthServiceStatusCode enum value. /// </summary> /// /// <param name="statusCodeId"> /// the integer status code id /// to be converted to a HealthServiceStatusCode enum value. /// </param> /// /// <returns> /// HealthVaultStatus code enum object appropriately initialized. /// </returns> /// internal static HealthServiceStatusCode GetStatusCode(int statusCodeId) { HealthServiceStatusCode statusCode = HealthServiceStatusCode.UnmappedError; // Update this when HealthServiceStatusCode enum gets new values if (statusCodeId < (int)HealthServiceStatusCode.Max) { statusCode = (HealthServiceStatusCode)statusCodeId; } return(statusCode); }
/// <summary> /// Helper method that allows the SDK to throw the appropriate /// HealthServiceException based on the status code indicating the error /// type. /// </summary> /// /// <param name="errorCode"> /// The status code representing the error which occurred. /// </param> /// /// <param name="error"> /// Information about an error that occurred while processing /// the request. /// </param> /// internal static HealthServiceException GetHealthServiceException( HealthServiceStatusCode errorCode, HealthServiceResponseError error) { HealthServiceException e = null; switch (errorCode) { case HealthServiceStatusCode.CredentialTokenExpired: e = new HealthServiceCredentialTokenExpiredException(error); break; case HealthServiceStatusCode.AuthenticatedSessionTokenExpired: e = new HealthServiceAuthenticatedSessionTokenExpiredException(error); break; case HealthServiceStatusCode.InvalidPerson: e = new HealthServiceInvalidPersonException(error); break; case HealthServiceStatusCode.InvalidRecord: e = new HealthServiceInvalidRecordException(error); break; case HealthServiceStatusCode.AccessDenied: e = new HealthServiceAccessDeniedException(error); break; case HealthServiceStatusCode.InvalidApplicationAuthorization: e = new HealthServiceInvalidApplicationAuthorizationException(error); break; case HealthServiceStatusCode.DuplicateCredentialFound: e = new HealthServiceApplicationDuplicateCredentialException(error); break; case HealthServiceStatusCode.MailAddressMalformed: e = new HealthServiceMailAddressMalformedException(error); break; case HealthServiceStatusCode.PasswordNotStrong: e = new HealthServicePasswordNotStrongException(error); break; case HealthServiceStatusCode.RecordQuotaExceeded: e = new HealthServiceRecordQuotaExceededException(error); break; case HealthServiceStatusCode.OtherDataItemSizeLimitExceeded : e = new HealthServiceOtherDataSizeLimitExceededException(error); break; default: e = new HealthServiceException(errorCode, error); break; } return e; }
/// <summary> /// Creates an instance of the <see cref="HealthServiceException"/> /// class with the specified error (status) code and error information. /// </summary> /// <param name="errorCode">The status code representing the error.</param> /// <param name="error">Information about an error that occurred while processing /// the request.</param> internal HealthServiceException( HealthServiceStatusCode errorCode, HealthServiceResponseError error) : this((int)errorCode, error) { }
/// <summary> /// Creates an instance of the <see cref="HealthServiceException"/> /// class with the specified unknown error (status) code. /// </summary> /// <remarks> /// The exception message generated will say that the error code is not recognized. /// </remarks> /// <param name="errorCode">The status code representing the error that occurred.</param> internal HealthServiceException(HealthServiceStatusCode errorCode) : this((int)errorCode, null) { }