guard against NPE

This commit is contained in:
danikov 2012-02-13 12:08:48 +00:00
parent 7e126f45aa
commit 8a926cea44
1 changed files with 1 additions and 1 deletions

View File

@ -45,7 +45,7 @@ public class ThrowVCloudErrorOn4xx implements Function<Exception, Object> {
public Object apply(Exception from) {
Iterable<HttpResponseException> throwables = Iterables.filter(Throwables.getCausalChain(from), HttpResponseException.class);
HttpResponseException exception = Iterables.getFirst(throwables, null);
if (exception != null && exception.getResponse().getStatusCode() >= 400 && exception.getResponse().getStatusCode() < 500) {
if (exception != null && exception.getResponse() != null && exception.getResponse().getStatusCode() >= 400 && exception.getResponse().getStatusCode() < 500) {
try {
Error error = JAXB.unmarshal(InputSuppliers.of(exception.getContent()).getInput(), Error.class);
throw new VCloudDirectorException(error);