diff options
Diffstat (limited to 'SendGrid/SendGridMail/Transport/Web.cs')
-rw-r--r-- | SendGrid/SendGridMail/Transport/Web.cs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/SendGrid/SendGridMail/Transport/Web.cs b/SendGrid/SendGridMail/Transport/Web.cs index 1458da8..69fed4c 100644 --- a/SendGrid/SendGridMail/Transport/Web.cs +++ b/SendGrid/SendGridMail/Transport/Web.cs @@ -179,7 +179,15 @@ namespace SendGrid var content = await response.Content.ReadAsStreamAsync();
- FindErrorsInResponse(content);
+ var errors = GetErrorsInResponse(content);
+
+ // API error
+ if (errors.Any())
+ throw new InvalidApiRequestException(response.StatusCode, errors, response.ReasonPhrase);
+
+ // Other error
+ if (response.StatusCode != HttpStatusCode.OK)
+ FindErrorsInResponse(content);
}
internal List<KeyValuePair<String, String>> FetchFormParams(ISendGrid message)
|