com.ionoscloud.s3.errors.ErrorResponseException Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ionos-cloud-sdk-s3 Show documentation
Show all versions of ionos-cloud-sdk-s3 Show documentation
IONOS Java SDK for Amazon S3 Compatible Cloud Storage
The newest version!
package com.ionoscloud.s3.errors;
import com.ionoscloud.s3.messages.ErrorResponse;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import okhttp3.Request;
import okhttp3.Response;
/** Thrown to indicate that error response is received when executing Amazon S3 operation. */
@SuppressWarnings("WeakerAccess")
public class ErrorResponseException extends ApiException {
private static final long serialVersionUID = -2933211538346902928L;
private final ErrorResponse errorResponse;
@SuppressFBWarnings(
value = "Se",
justification = "There's really no excuse except that nobody has complained")
private final Response response;
/** Constructs a new ErrorResponseException with error response and HTTP response object. */
public ErrorResponseException(ErrorResponse errorResponse, Response response, String httpTrace) {
super(errorResponse.message(), httpTrace);
this.errorResponse = errorResponse;
this.response = response;
}
/** Returns ErrorResponse contains detail of what error occured. */
public ErrorResponse errorResponse() {
return this.errorResponse;
}
public Response response() {
return this.response;
}
@Override
public String toString() {
Request request = response.request();
return "error occurred\n"
+ errorResponse.toString()
+ "\n"
+ "request={"
+ "method="
+ request.method()
+ ", "
+ "url="
+ request.url()
+ ", "
+ "headers="
+ request
.headers()
.toString()
.replaceAll("Signature=([0-9a-f]+)", "Signature=*REDACTED*")
.replaceAll("Credential=([^/]+)", "Credential=*REDACTED*")
+ "}\n"
+ "response={"
+ "code="
+ response.code()
+ ", "
+ "headers="
+ response.headers()
+ "}\n";
}
}