use of com.synopsys.integration.detect.lifecycle.OperationException in project synopsys-detect by blackducksoftware.
the class OperationWrapper method wrapped.
public <T> T wrapped(Operation operation, OperationSupplier<T> supplier, Runnable successConsumer, Consumer<Exception> errorConsumer) throws OperationException {
try {
T value = supplier.execute();
operation.success();
successConsumer.run();
return value;
} catch (InterruptedException e) {
operation.error(e);
// Restore interrupted state...
Thread.currentThread().interrupt();
errorConsumer.accept(e);
throw new OperationException(e);
} catch (OperationException e) {
operation.error(e);
errorConsumer.accept(e);
throw e;
} catch (Exception e) {
operation.error(e);
errorConsumer.accept(e);
throw new OperationException(e);
} finally {
operation.finish();
}
}
use of com.synopsys.integration.detect.lifecycle.OperationException in project synopsys-detect by blackducksoftware.
the class ExceptionUtility method logException.
public void logException(Exception e) {
if (e instanceof OperationException) {
OperationException operationException = (OperationException) e;
logException(operationException.getException());
} else if (e instanceof DetectUserFriendlyException) {
if (e.getCause() != null) {
logger.debug(e.getCause().getMessage(), e.getCause());
}
logger.error(e.getMessage());
} else if (e instanceof BlackDuckTimeoutExceededException) {
logger.error(BLACKDUCK_TIMEOUT_ERROR_MESSAGE);
logger.error(e.getMessage());
} else if (e instanceof BlackDuckApiException) {
BlackDuckApiException be = (BlackDuckApiException) e;
logger.error(BLACKDUCK_ERROR_MESSAGE);
logger.error(be.getMessage());
logger.debug(be.getBlackDuckErrorCode());
logger.error(be.getOriginalIntegrationRestException().getMessage());
} else if (e instanceof IntegrationRestException) {
logger.error(BLACKDUCK_ERROR_MESSAGE);
logger.debug(e.getMessage(), e);
} else if (e instanceof IntegrationException) {
logger.error(BLACKDUCK_ERROR_MESSAGE);
logger.debug(e.getMessage(), e);
} else if (e instanceof InvalidPropertyException) {
logger.error("A configuration error occured");
logger.debug(e.getMessage(), e);
} else {
logUnrecognizedException(e);
}
}
Aggregations