Skip to content
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

add error information for when sonatype fails #32

Merged
merged 2 commits into from
Mar 19, 2017

Conversation

deanhiller
Copy link

This adds the info so e.getMessage() when used which is printed when using --stacktrace. Also, we log the same thing as well for those not using --stacktrace as this is a pretty important failure and one needs to know the issue that occurred from the remote end.

@deanhiller
Copy link
Author

deanhiller commented Dec 23, 2016

The result after using my local install of this plugin is something like this...

Caused by: org.gradle.api.UncheckedIOException: org.apache.http.client.HttpResponseException: 500:Server Error  body=[errors:[[id:*, msg:Unhandled: Staging repository is already transitioning: orgwebpieces-1084]]]
        at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:43)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:78)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:228)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:221)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:210)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:621)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:604)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
        ... 68 more
Caused by: org.apache.http.client.HttpResponseException: 500:Server Error  body=[errors:[[id:*, msg:Unhandled: Staging repository is already transitioning: orgwebpieces-1084]]]
        at io.codearte.gradle.nexus.infra.SimplifiedHttpJsonRestClient.post(SimplifiedHttpJsonRestClient.groovy:67)
        at io.codearte.gradle.nexus.logic.RepositoryPromoter.promoteRepositoryWithIdAndStagingProfileId(RepositoryPromoter.groovy:15)
        at io.codearte.gradle.nexus.PromoteRepositoryTask.doAction(PromoteRepositoryTask.groovy:23)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
        ... 75 more

Copy link
Member

@szpak szpak left a comment

Choose a reason for hiding this comment

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

And thanks for the contribution :).

HttpResponseDecorator response = (HttpResponseDecorator)restClient.post(params)
log.warn("POST response data: ${response.data}")
try {
//TODO: Add better error handling (e.g. display error message received from server, not only 500 + not fail on 404 in 'text/html')
Copy link
Member

Choose a reason for hiding this comment

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

This comment is no longer valid after your changes :).

HttpResponseDecorator resp = e.getResponse();
String message = "${resp.statusLine.statusCode}:${resp.statusLine.reasonPhrase} body=${resp.data}"
log.error("POST response failed. ${message}")
throw new HttpResponseException(e.getStatusCode(), message)
Copy link
Member

Choose a reason for hiding this comment

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

We lose original stacktrace. Please include e as a cause.

//TODO: Add better error handling (e.g. display error message received from server, not only 500 + not fail on 404 in 'text/html')
HttpResponseDecorator response = (HttpResponseDecorator)restClient.post(params)
log.warn("POST response data: ${response.data}")
} catch(groovyx.net.http.HttpResponseException e) {
Copy link
Member

Choose a reason for hiding this comment

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

Missing space after catch

//put all information there (status code, error str, body of response in case they put more error information there)

HttpResponseDecorator resp = e.getResponse();
String message = "${resp.statusLine.statusCode}:${resp.statusLine.reasonPhrase} body=${resp.data}"
Copy link
Member

Choose a reason for hiding this comment

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

(two spaces) before body - one would be enough.

String message = "${resp.statusLine.statusCode}:${resp.statusLine.reasonPhrase} body=${resp.data}"
log.error("POST response failed. ${message}")
throw new HttpResponseException(e.getStatusCode(), message)
}
Copy link
Member

Choose a reason for hiding this comment

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

Please reformat this code fragment in general. It seems your are using tabs instead of spaces.

Copy link
Member

Choose a reason for hiding this comment

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

I created #33 to better handle that.

Copy link
Member

@szpak szpak left a comment

Choose a reason for hiding this comment

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

And thanks for the contribution :).

@szpak
Copy link
Member

szpak commented Dec 23, 2016

And you can also squash those commits into one.

@szpak
Copy link
Member

szpak commented Jan 18, 2017

@deanhiller Can you fix the things I mentioned in the code review to make this PR being merged?

@szpak szpak merged commit ecdc296 into Codearte:master Mar 19, 2017
@szpak
Copy link
Member

szpak commented Mar 19, 2017

I reworked it your changes and merged them manually.

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.

3 participants