private void HandleError(HttpStatusCode statusCode, string response, bool isOAuthError = false) { switch (statusCode) { case HttpStatusCode.Unauthorized: EchosignError error = JsonConvert.DeserializeObject <EchosignError>(response); throw new EchosignOAuthException(error); case HttpStatusCode.BadRequest: if (!isOAuthError) // echosign returns different json for oAuth calls { EchosignErrorCode errorCode = JsonConvert.DeserializeObject <EchosignErrorCode>(response); throw new EchosignBadRequestException(errorCode); } else { EchosignError oAuthError = JsonConvert.DeserializeObject <EchosignError>(response); throw new EchosignOAuthException(oAuthError); } default: EchosignErrorCode defaultError = JsonConvert.DeserializeObject <EchosignErrorCode>(response); throw new EchosignBadRequestException(defaultError); } }
public EchosignBadRequestException(EchosignErrorCode error) { this.Error = error; }