//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Constructor. </summary> /// /// <param name="responseType"> The result. </param> /// <param name="responseCategory"> Category the response belongs to. </param> //////////////////////////////////////////////////////////////////////////////////////////////////// public TangoCardServiceException(ServiceResponseEnum responseType, FailureResponse response) : this(responseType, response, string.Empty) { }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Constructor. </summary> /// /// <param name="responseType"> The result. </param> /// <param name="responseCategory"> Category the response belongs to. </param> /// <param name="message"> The message. </param> //////////////////////////////////////////////////////////////////////////////////////////////////// public TangoCardServiceException(ServiceResponseEnum responseType, FailureResponse response, string message) : base(message) { this.ResponseType = responseType; this.Response = response; }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Throw on error. </summary> /// /// Throws a Service Exception if the given json sting is not of type "SUCCESS". /// /// <exception cref="TangoCardServiceException"> Thrown when a service error condition occurs. </exception> /// <exception cref="Exception"> Thrown when an exception error condition occurs. </exception> /// /// <param name="responseJsonEncoded"> The json body. </param> /// <param name="jsonSettings"> The json settings. </param> //////////////////////////////////////////////////////////////////////////////////////////////////// public static void ThrowOnError(ServiceResponseEnum enumResponseType, JObject responseJson) { switch (enumResponseType) { case ServiceResponseEnum.SUCCESS: break; case ServiceResponseEnum.INS_FUNDS: { InsufficientFundsResponse response = responseJson.Deserialize<InsufficientFundsResponse>(); throw new TangoCardServiceException(enumResponseType, response); } case ServiceResponseEnum.INV_CREDENTIAL: { InvalidCredentialsResponse response = responseJson.Deserialize<InvalidCredentialsResponse>(); throw new TangoCardServiceException(enumResponseType, response); } case ServiceResponseEnum.SYS_ERROR: { SystemErrorResponse response = responseJson.Deserialize<SystemErrorResponse>(); throw new TangoCardServiceException(enumResponseType, response); } case ServiceResponseEnum.INV_INPUT: { InvalidInputResponse response = responseJson.Deserialize<InvalidInputResponse>(); throw new TangoCardServiceException(enumResponseType, response); } case ServiceResponseEnum.INS_INV: { InsufficientInventoryResponse response = responseJson.Deserialize<InsufficientInventoryResponse>(); throw new TangoCardServiceException(enumResponseType, response); } default: { throw new TangoCardSdkException(message: "Unknown handled response type"); } } }