Skip to content

Conversation

tdltdl
Copy link

@tdltdl tdltdl commented Sep 11, 2024

… cache poisoning.

WARNING This change is not a drop in replacement as if we get 403 because the token is incorrect, a checked exception is raised.

Also note that, if an empty or null token is passed, it is now a fail fast (instead of getting a null pointer exception at the first request)

…s with cache poisoning.

WARNING This change is not a drop in replacement as if we get 403 because the token is incorrect, a checked exception is raised.
Also note that, if an empty or null token is passed, it is now a fail fast (instead of getting a null pointer exception at the first request)
Copy link
Contributor

@max-ipinfo max-ipinfo left a comment

Choose a reason for hiding this comment

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

@tdltdl thanks for sending your PR. I will continue to bring timely feedback from now on so we can create new package versions after each PR.

Please go over the exception restructuring suggested, with all HTTP exceptions inheriting from HttpErrorException. That includes simplifying all throws clauses to throws HttpErrorException where it makes sense.

Could you also update README.md' s Error section and document the new errors hierarchically?

I'll help you update the documentation for every exception after your next change.

return this;
}

public IPinfo build() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this have throws IllegalArgumentException?

* <p>That likely indicates that the token is either missing, incorrect or expired.
* It is a checked exception so, if you have multiple tokens (example during transition), you can fall back to another token.</p>
*/
public class InvalidTokenException extends Exception {
Copy link
Contributor

@max-ipinfo max-ipinfo Feb 22, 2025

Choose a reason for hiding this comment

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

Now that we've introduced a proper HttpErrorException class, we should have InvalidTokenException and RateLimitedException also inherit from it, as they are technically exceptions stemming from an HTTP error response.

This helps simplify the design (no need to disambiguate everywhere with throws RateLimitedException, InvalidTokenException ) and it also helps clarify (in code) that they stem from the same source.

}

public abstract T handle() throws RateLimitedException;
public abstract T handle() throws RateLimitedException, InvalidTokenException;
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be simplified to throws HttpErrorException

public abstract T handle() throws RateLimitedException, InvalidTokenException;

public Response handleRequest(Request.Builder request) throws RateLimitedException {
public Response handleRequest(Request.Builder request) throws RateLimitedException, InvalidTokenException {
Copy link
Contributor

Choose a reason for hiding this comment

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

Similarly, this can be simplified throws HttpErrorException

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