AshleyMedway / MailJet.NET

.NET Client for MailJet
MIT License
8 stars 11 forks source link

Add an explanation when receiving an HTTP 401 exception #26

Closed emergentSushi closed 7 years ago

emergentSushi commented 7 years ago

Hi,

Thanks for the library, it's been a great help :)

I discovered that I was using the wrong key/secret when trying to send emails, but the error I received was NullReferenceException, which took a while to figure out (since the result gets an empty Content field in this case, it gets deserialized to null).

So I added a check to SendMessage(RestRequest request) to detect HTTP 401's and add an explanation.

Happy to change this if you think there's a better way of informing users of invalid credentials.

Cheers, Mat

AshleyMedway commented 7 years ago

Neat 👍 I haven't spent much time on this project recently but do need to get back into it