-
Notifications
You must be signed in to change notification settings - Fork 582
Upgrade Error Handling Functionality #404
New issue
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
Comments
Hello @KaptenJon, Currently, you can retrieve the error messages as follows: https://github.com/sendgrid/sendgrid-csharp/blob/master/TROUBLESHOOTING.md#error and the status codes we return are: https://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html Unfortunately, I'm not quite sure how to reproduce your error. I have not tried overriding With Best Regards, Elmer |
Overriding is the wrong word maybe :-) do System.Net.ServicePointManager.ServerCertificateValidationCallback = and in the method you provide return false.
I used dotnetcore if that matter for the specific sendgridclient.
You can also see in the source code, as I tried to explain, that the exception is not provided to the user but only a very general text,and ok status code, making it hard for the user of the lib.
Skickat från min Sony Xperia™-smartphone
…---- Elmer Thomas skrev ----
Hello @KaptenJon<https://github.com/KaptenJon>,
Currently, you can retrieve the error messages as follows: https://github.com/sendgrid/sendgrid-csharp/blob/master/TROUBLESHOOTING.md#error and the status codes we return are: https://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html
Unfortunately, I'm not quite sure how to reproduce your error. I have not tried overriding System.Net.ServicePointManager.ServerCertificateValidationCallback. Do you mind providing some additional code so I can try to reproduce?
With Best Regards,
Elmer
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#404 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AKQ1Sp1NZDMGs7_kTIN3hHswpgo6KTDDks5rew4-gaJpZM4MG-8E>.
|
Hi @KaptenJon, If there is an exception, we current include the exception message in the response content, like so: https://github.com/sendgrid/sendgrid-csharp/blob/master/src/SendGrid/SendGridClient.cs#L377, then you can access the error message like this: Does that help? |
Hi, I actually totally missed that reading the code :) And I also still think the status code shouldent be ok. I am not an expert in http responses but how about HttpStatusCode.Unauthorized |
|
Ah, thanks for the additional details! We need to refactor our error handling. I will leave this ticket open to track the progress and I've added this to our backlog. I'm changing the title of this issue to reflect it's new purpose. Thanks! |
No thanks to you, great work!
Skickat från min Sony Xperia™-smartphone
…---- Elmer Thomas skrev ----
Ah, thanks for the additional details!
We need to refactor our error handling. I will leave this ticket open to track the progress and I've added this to our backlog.
I'm changing the title of this issue to reflect it's new purpose.
Thanks!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#404 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AKQ1SiW-c3Qq3ikFdv2ZFL6jQTJz-ENCks5rfdRjgaJpZM4MG-8E>.
|
Error handling should not return OK if it isn't. I'd prefer if the exception was not caught so i could handle different cases in my code. As a workaround I added some code that looks for ".NET HttpRequestException" or ".NET Exception" in the result if status is OK, then i consider it an exception and adds some retry. |
Maybe a better workaround for you is to download the source code for the class. There are no dependecies to other parts and then simple to modify.
Skickat från min Sony Xperia™-smartphone
…---- Anders Elvik skrev ----
Error handling should not return OK if it isn't. I'd prefer if the exception was not caught so i could handle different cases in my code.
As a workaround I added some code that looks for ".NET HttpRequestException" or ".NET Exception" in the result if status is OK, then i consider it an exception and adds some retry.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#404 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AKQ1St69Jk0o6-GCo6FUEjMJtOh9DwOkks5rhXW-gaJpZM4MG-8E>.
|
I have added your vote to this issue to help increase the priority in our backlog. Thanks for taking the time to reach out :) |
@KaptenJon Will also need the dto classes, but that should not be to many so I'll try that |
Hello everyone, This issue has been resolved with: #434 |
Beautiful!!
…---- Elmer Thomas skrev ----
Hello everyone,
This issue has been resolved with: #434<#434>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#404 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AKQ1SkG9OgReOkWFg_xusyTFODfaepYAks5rvl3BgaJpZM4MG-8E>.
|
Uh oh!
There was an error while loading. Please reload this page.
Issue Summary
I override System.Net.ServicePointManager.ServerCertificateValidationCallback (in this case not in a good way) and sendgrids certificate was treated as a bad certificate. When I user SendGridClient it throws away the underlying exception replying with a HttpResponse OK leaving the developer with no clue. Using the nuget package makes it even harder though I can't step through the code.
I suggest to return an other http response statuscode and include the exception messege (maybe also inner exception message) with the returned response.
Steps to Reproduce
1 Override System.Net.ServicePointManager.ServerCertificateValidationCallback =
(sender, certificate, chain, errors) =>
{ return false;}
2. Use sendgridclient and see your ok message (but now send email)
Technical details:
The text was updated successfully, but these errors were encountered: