Skip to content

Better error messages#254

Merged
kohsuke merged 2 commits intohub4j:masterfrom
cyrille-leclerc:better-error-messages
Mar 12, 2016
Merged

Better error messages#254
kohsuke merged 2 commits intohub4j:masterfrom
cyrille-leclerc:better-error-messages

Conversation

@cyrille-leclerc
Copy link
Contributor

Better error message:

  • Introduce HttpException, subclass of IOException with url, http responseCode and http responseMessage to help exception handling.
  • Add a FINEST log message in GitHub.isCredentialsValid() in case of exception as we silently swallow this exception.

…n with url, http responseCode and http responseMessage to help exception handling.
@cyrille-leclerc
Copy link
Contributor Author

@reviewbybees esp @recena @oleg-nenashev

@ghost
Copy link

ghost commented Mar 6, 2016

This pull request originates from a CloudBees employee. At CloudBees, we require that all pull requests be reviewed by other CloudBees employees before we seek to have the change accepted. If you want to learn more about our process please see this explanation.

retrieve().to("/user", GHUser.class);
return true;
} catch (IOException e) {
logger.log(Level.FINEST, "Exception validating credentials on {0} with login {1}: {2}", new Object[]{this.apiUrl, this.login, e, e});
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably FINE would be appropriate.

Copy link
Contributor

Choose a reason for hiding this comment

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

🐛 you are trying to pass four parameters to a three-argument message parameter; probably you meant to put the last e outside the braces, but this does not work because the preformatted overloads do not also accept Throwable. Also including Throwable.toString in the message is pointless when you are including the full stack trace anyway. So what you meant was probably something like

logger.log(Level.FINE, "Exception validating credentials on " + apiUrl + " with login " + login, e);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I'll never get on well with java.util.logging :-)

@cyrille-leclerc
Copy link
Contributor Author

@jglick I have updated the code according to your recommendations!

@kohsuke kohsuke merged commit 56379bb into hub4j:master Mar 12, 2016
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.

4 participants