We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When network issues occur, e.g. no network connection, the low level error code is not returned. This could be the solution:
private SentMessageData SendMessage(RestRequest request) { request.RequestFormat = DataFormat.Json; request.JsonSerializer = NewtonsoftJsonSerializer.Default; var result = WebClient.Execute(request); if (result.ResponseStatus == ResponseStatus.Completed && (result.StatusCode == HttpStatusCode.NoContent)) return null; if (result.ResponseStatus == ResponseStatus.Completed && result.StatusCode == HttpStatusCode.Unauthorized) throw new UnauthorizedAccessException("MailJet returned an HTTP 401 exception, please check your credentials"); if (result.ResponseStatus == ResponseStatus.Completed && result.StatusCode >= HttpStatusCode.BadRequest) throw new HttpException((int)result.StatusCode, result.StatusCode.ToString()); if (result.ErrorMessage != null && String.IsNullOrWhiteSpace(result.Content)) { throw new Exception(result.ErrorMessage); } else { var error = JsonConvert.DeserializeObject<ErrorResponse>(result.Content); if (!String.IsNullOrWhiteSpace(error.ErrorInfo) || !String.IsNullOrWhiteSpace(error.ErrorMessage)) throw new Exception(String.Format("{0}\n{1}", error.ErrorMessage, error.ErrorMessage)); } var data = JsonConvert.DeserializeObject<SentMessageData>(result.Content); return data; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
When network issues occur, e.g. no network connection, the low level error code is not returned.
This could be the solution:
The text was updated successfully, but these errors were encountered: