mirror of https://github.com/apache/jclouds.git
Error handler check for empty payload
This commit is contained in:
parent
b786178a90
commit
fd616ddbed
|
@ -55,11 +55,12 @@ public class VCloudDirectorErrorHandler implements HttpErrorHandler {
|
||||||
: String.format("%s -> %s", command.getCurrentRequest().getRequestLine(), response.getStatusLine());
|
: String.format("%s -> %s", command.getCurrentRequest().getRequestLine(), response.getStatusLine());
|
||||||
Exception exception = new HttpResponseException(command, response, message);
|
Exception exception = new HttpResponseException(command, response, message);
|
||||||
|
|
||||||
// Try to create a VCloudDirectorException from XML payload
|
// Try to create a VCloudDirectorException from XML payload, if it exists
|
||||||
if (response.getPayload().getContentMetadata().getContentType().startsWith(VCloudDirectorMediaType.ERROR)) {
|
if (response.getPayload() != null && response.getPayload().getContentMetadata().getContentType().startsWith(VCloudDirectorMediaType.ERROR)) {
|
||||||
try {
|
try {
|
||||||
Error error = JAXB.unmarshal(InputSuppliers.of(data).getInput(), Error.class);
|
Error error = JAXB.unmarshal(InputSuppliers.of(data).getInput(), Error.class);
|
||||||
exception = new VCloudDirectorException(error);
|
exception = new VCloudDirectorException(error);
|
||||||
|
message = error.getMessage();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Throwables.propagate(e);
|
Throwables.propagate(e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue