-
Notifications
You must be signed in to change notification settings - Fork 18
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
base: master
Are you sure you want to change the base?
SteamApiException's status code exposure #53
Conversation
- statusCode exposed
- throws 400 status code by default
@@ -9,32 +9,44 @@ public enum Cause { | |||
} | |||
|
|||
private String message; | |||
private final Integer statusCode; |
There was a problem hiding this comment.
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? 🤔
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
Added exposure of a status code to make it possible to handle it in a required way.