Pterodactyl4J icon indicating copy to clipboard operation
Pterodactyl4J copied to clipboard

[BUG] Client get request throws HttpException instead of LoginException

Open Raft08 opened this issue 6 months ago • 8 comments

Hello, I'm trying to make some check ups before running my code.

I do this code to get some information and to check if the panel is acccessible and I have a correct API token.

    private void checkoutAccount() {
        try {
            Account account = this.client.retrieveAccount()
                    .timeout(this.configuration.getTimeout(), TimeUnit.MILLISECONDS)
                    .execute();

            if (!account.isRootAdmin())
                Bootstrap.crash("Pterodactyl account is missing permissions. Administration permissions are required by AtlasNetwork.");

            LOGGER.info("Connected as {}!", account.getUserName());
        } catch (LoginException | HttpException e) {
            Bootstrap.crash("Could not open connection with '" +
                    this.configuration.getUrl() + ": Invalid Authentication Token!");
        }
    }

But when I'm unauthenticated. it throws HttpException instead of LoginException is this expected behaviour?

The javadoc says "Throws: LoginException – If the API key is incorrect"

Raft08 avatar Dec 26 '23 13:12 Raft08