Skip to content

SteamApiException's status code exposure #53

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Fugasss
Copy link

@Fugasss Fugasss commented May 23, 2025

Added exposure of a status code to make it possible to handle it in a required way.

Fugasss added 2 commits May 22, 2025 17:44
- statusCode exposed
- throws 400 status code by default
@@ -9,32 +9,44 @@ public enum Cause {
}

private String message;
private final Integer statusCode;
Copy link
Owner

Choose a reason for hiding this comment

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

As there are a few cases where it is possible that the Exception is created and there is no HTTP Error Code to associate with (see for example SteamWebApiRequestHandler#59), perhaps it would be best to make this into a private final Optional<Integer> statusCode? What do you think? 🤔

Copy link
Author

@Fugasss Fugasss May 25, 2025

Choose a reason for hiding this comment

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

I think it would be more appropriate to use IllegalArgumentException than SteamApiException(SteamWebApiRequestHandler#59), because it clearly indicates that the wrong argument is passed. In my opinion, SteamApiException should be used only in the cases of interaction with the steam api - for example, we made a request and got 429 Too Many Requests. So there will be no way, when the status code will be null.

Copy link
Owner

Choose a reason for hiding this comment

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

Hmmm you might be right. I will try to get around to make the changes you suggest, however this will have to wait until after I return from my vacation beginning tomorrow so expect it no earlier than sometime in June. Hope that's ok with you.

super(message);
this.statusCode = statusCode;
}

public SteamApiException(Cause cause, Throwable exceptionCause) {

super(exceptionCause);

switch (cause) {
Copy link
Owner

Choose a reason for hiding this comment

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

It should be possible to add the other causes here as well, right?

Copy link
Author

Choose a reason for hiding this comment

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

It is possible to add causes for the most frequent cases: 400, 401, 403, 404, 429, 500, 503. What do you think about these cases?

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.

2 participants