com.github.davidmoten.aws.lw.client.internal.ExceptionFactoryDefault Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aws-lightweight-client-java Show documentation
Show all versions of aws-lightweight-client-java Show documentation
Lightweight client for all AWS services (but still with useful builders and XML parser)
The newest version!
package com.github.davidmoten.aws.lw.client.internal;
import java.nio.charset.StandardCharsets;
import java.util.Optional;
import com.github.davidmoten.aws.lw.client.ExceptionFactory;
import com.github.davidmoten.aws.lw.client.Response;
import com.github.davidmoten.aws.lw.client.ServiceException;
public class ExceptionFactoryDefault implements ExceptionFactory{
@Override
public Optional extends RuntimeException> create(Response r) {
if (r.isOk()) {
return Optional.empty();
} else {
return Optional.of(new ServiceException(r.statusCode(),
new String(r.content(), StandardCharsets.UTF_8)));
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy