Skip to content
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

Error reporting improvements #22

Merged
merged 15 commits into from
Sep 7, 2022
Merged

Error reporting improvements #22

merged 15 commits into from
Sep 7, 2022

Conversation

Zlata-Zueva
Copy link
Contributor

@Zlata-Zueva Zlata-Zueva commented Sep 6, 2022

  • Replaces all SystemExceptions with more meaningful errors and improves messages.
  • Makes sure exceptions get stringified properly.
  • Adds error logs to tests on failures during resources clean up.

Partly addresses #12, but there are still places to improve.

TODO:

  • Update changelog
  • Bump up SDK version

@Zlata-Zueva Zlata-Zueva linked an issue Sep 6, 2022 that may be closed by this pull request
@larf311 larf311 requested a review from bradlo September 6, 2022 15:34
@larf311
Copy link

larf311 commented Sep 6, 2022

I notice the Java SDK just returns the HTTP errors directly (e.g. 404 for not found). I suspect that was a deliberate choice by @bradlo and that we should probably do the same here.

Copy link
Collaborator

@bradlo bradlo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. One question, but mostly just curious. And thank you for the updates to the changelog.

{
StatusCode = statusCode;
Response = response;
Headers = headers;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

am curious why the api exception carries the HTTP headers? in the other SDKs we generally try to abstract away transport details at the API layer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bradlo we really need that for the request id, as that's always important for tracing. We could extract the X-Request-ID header value and pass it directly if we know the exact header name.

CHANGELOG.md Outdated Show resolved Hide resolved
Zlata-Zueva and others added 2 commits September 7, 2022 19:29
if (status != 404 && status < 500)
{
return;
}
Copy link
Contributor

@NRHelmi NRHelmi Sep 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens if resource is forbidden (403) ? Do we swallow client errors other than 404 ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NRHelmi yeah, we mostly wanted to leave the behaviour as it was before. I think it's better for the SDK team to agree on the http status code handling to be consistent across all of the SDKs.

The reason for 5xx is simple, as we run into them (occasionally we do), we want to be able to see the request id in logs.

Your point is very valid though, but we'd like to leave it out of the scope of this PR is that's fine with you?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the clarification, can we create an issue as part of the project ?
cc @bradlo

@@ -293,14 +314,14 @@ private async Task<AccessToken> RequestAccessTokenAsync(string host, ClientCrede
var resp = await RequestHelperAsync("POST", creds.ClientCredentialsUrl, data);
if (!(resp is string stringResponse))
{
throw new SystemException("Unexpected response type");
throw new InvalidResponseException("Unexpected response type, expected a string", resp);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe also include the current response type in the exception message

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NRHelmi addressed in the latest commit. Thank you.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you 🙏

Copy link
Contributor

@NRHelmi NRHelmi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you :)

@Zlata-Zueva Zlata-Zueva merged commit c21b2d6 into main Sep 7, 2022
@Zlata-Zueva Zlata-Zueva deleted the zz-exceptions-hierarchy branch September 7, 2022 23:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants