com.applitools.connectivity.api.AbstractAsyncCallback Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of eyes-common-java5 Show documentation
Show all versions of eyes-common-java5 Show documentation
Common code for Applitools Eyes Java SDK projects
package com.applitools.connectivity.api;
import com.applitools.eyes.Logger;
import com.applitools.eyes.TaskListener;
import com.applitools.eyes.logging.Stage;
import com.applitools.utils.GeneralUtils;
public abstract class AbstractAsyncCallback implements AsyncRequestCallback {
private final Logger logger;
private final TaskListener listener;
public AbstractAsyncCallback(Logger logger, TaskListener listener) {
this.logger = logger;
this.listener = listener;
}
protected abstract T onCompleteInner(Response response);
@Override
public void onComplete(Response response) {
try {
listener.onComplete(onCompleteInner(response));
} catch (Throwable t) {
onFail(t);
} finally {
response.close();
}
}
@Override
public void onFail(Throwable throwable) {
GeneralUtils.logExceptionStackTrace(logger, Stage.GENERAL, throwable);
listener.onFail();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy