com.teamscale.jacoco.agent.upload.UploaderException Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of teamscale-jacoco-agent Show documentation
Show all versions of teamscale-jacoco-agent Show documentation
JVM profiler that simplifies various aspects around recording and uploading test coverage
package com.teamscale.jacoco.agent.upload;
import okhttp3.ResponseBody;
import retrofit2.Response;
import java.io.IOException;
/**
* Exception thrown from an uploader. Either during the upload or in the validation process.
*/
public class UploaderException extends Exception {
/** Constructor */
public UploaderException(String message, Exception e) {
super(message, e);
}
/** Constructor */
public UploaderException(String message) {
super(message);
}
/** Constructor */
public UploaderException(String message, Response response) {
super(createResponseMessage(message, response));
}
private static String createResponseMessage(String message, Response response) {
try {
String errorBodyMessage = response.errorBody().string();
return String.format("%s (%s): \n%s", message, response.code(), errorBodyMessage);
} catch (IOException | NullPointerException e) {
return message;
}
}
}