-
Notifications
You must be signed in to change notification settings - Fork 26
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
package io.codearte.gradle.nexus.infra | ||
|
||
import org.apache.http.client.HttpResponseException; | ||
|
||
import groovy.transform.CompileStatic | ||
import groovy.util.logging.Slf4j | ||
import groovyx.net.http.ContentType | ||
|
@@ -51,8 +53,18 @@ class SimplifiedHttpJsonRestClient { | |
Map params = createAndInitializeCallParametersMap() | ||
params.body = content | ||
log.debug("POST request content: $content") | ||
//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}") | ||
try { | ||
//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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing space after |
||
//Apache' HttpResponseException ONLY puts the 2nd param in the e.getMessage which will be printed so | ||
//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}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
log.error("POST response failed. ${message}") | ||
throw new HttpResponseException(e.getStatusCode(), message) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We lose original stacktrace. Please include |
||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I created #33 to better handle that. |
||
} | ||
} |
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.
This comment is no longer valid after your changes :).