-
Notifications
You must be signed in to change notification settings - Fork 370
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
Chain the cause exception and log in case of failure #159
Chain the cause exception and log in case of failure #159
Conversation
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.
lgtm
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. |
@@ -1019,6 +1019,9 @@ private void checkApiUrlValidity(GitHub github) throws IOException { | |||
github.checkApiUrlValidity(); | |||
} catch (HttpException e) { | |||
String message = String.format("It seems %s is unreachable", apiUri == null ? GITHUB_URL : apiUri); | |||
AbortException abortException = new AbortException(message); | |||
abortException.initCause(e); | |||
LOGGER.log(Level.WARNING, "Issue while checking GitHub URL validity", e); |
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.
Why not throw abortException
instead of throw new AbortException(message);
?
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.
AbortException is designed to not have stacktraces and etc. It should clearly say what fails. But seems here @batmat trying to use it in a wrong way.
The right way is to print informative errors to listener (not stacktraces) and then fail with AbortException.
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.
and @recena right, this code wouldn't even work. just a dead store that should fail from findbugs.
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.
AbortException
should be thrown (no printing to log) when there is a user-level mistake. It was not appropriate here IMO. Should be something like
} catch (HttpException e) {
String message = String.format("It seems %s is unreachable", apiUri == null ? GITHUB_URL : apiUri);
throw new IOException(message, e);
}
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.
Should be throw new IOException
.
The critical part is that we should throw an exception. AbortException
should, in general, be reserved for aborting the job (at least from plugin code). IOException
and InterruptedException
should be thrown from the SCMSource implementations during scanning if any IO error or if interrupted respectively.
@@ -1019,6 +1019,9 @@ private void checkApiUrlValidity(GitHub github) throws IOException { | |||
github.checkApiUrlValidity(); | |||
} catch (HttpException e) { | |||
String message = String.format("It seems %s is unreachable", apiUri == null ? GITHUB_URL : apiUri); | |||
AbortException abortException = new AbortException(message); | |||
abortException.initCause(e); | |||
LOGGER.log(Level.WARNING, "Issue while checking GitHub URL validity", e); |
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.
AbortException
should be thrown (no printing to log) when there is a user-level mistake. It was not appropriate here IMO. Should be something like
} catch (HttpException e) {
String message = String.format("It seems %s is unreachable", apiUri == null ? GITHUB_URL : apiUri);
throw new IOException(message, e);
}
@@ -1019,6 +1019,9 @@ private void checkApiUrlValidity(GitHub github) throws IOException { | |||
github.checkApiUrlValidity(); | |||
} catch (HttpException e) { | |||
String message = String.format("It seems %s is unreachable", apiUri == null ? GITHUB_URL : apiUri); | |||
AbortException abortException = new AbortException(message); | |||
abortException.initCause(e); | |||
LOGGER.log(Level.WARNING, "Issue while checking GitHub URL validity", e); |
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.
Should be throw new IOException
.
The critical part is that we should throw an exception. AbortException
should, in general, be reserved for aborting the job (at least from plugin code). IOException
and InterruptedException
should be thrown from the SCMSource implementations during scanning if any IO error or if interrupted respectively.
0251d10
to
e307bb5
Compare
@KostyaSha @recena @jglick @stephenc comments addressed. Thanks! |
My org folder scanning is failing, and I don't know why.
From https://twitter.com/githubstatus there doesn't seem to be an issue right now. So overall, having more data to diagnose such issue in the future would be definitely helpful.
@reviewbybees