Search in sources :

Example 1 with OperationException

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();
    }
}
Also used : OperationException(com.synopsys.integration.detect.lifecycle.OperationException) DetectUserFriendlyException(com.synopsys.integration.detect.configuration.DetectUserFriendlyException) IntegrationException(com.synopsys.integration.exception.IntegrationException) IOException(java.io.IOException) OperationException(com.synopsys.integration.detect.lifecycle.OperationException)

Example 2 with OperationException

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);
    }
}
Also used : IntegrationRestException(com.synopsys.integration.rest.exception.IntegrationRestException) DetectUserFriendlyException(com.synopsys.integration.detect.configuration.DetectUserFriendlyException) IntegrationException(com.synopsys.integration.exception.IntegrationException) BlackDuckApiException(com.synopsys.integration.blackduck.exception.BlackDuckApiException) BlackDuckTimeoutExceededException(com.synopsys.integration.blackduck.exception.BlackDuckTimeoutExceededException) InvalidPropertyException(com.synopsys.integration.configuration.config.InvalidPropertyException) OperationException(com.synopsys.integration.detect.lifecycle.OperationException)

Aggregations

DetectUserFriendlyException (com.synopsys.integration.detect.configuration.DetectUserFriendlyException)2 OperationException (com.synopsys.integration.detect.lifecycle.OperationException)2 IntegrationException (com.synopsys.integration.exception.IntegrationException)2 BlackDuckApiException (com.synopsys.integration.blackduck.exception.BlackDuckApiException)1 BlackDuckTimeoutExceededException (com.synopsys.integration.blackduck.exception.BlackDuckTimeoutExceededException)1 InvalidPropertyException (com.synopsys.integration.configuration.config.InvalidPropertyException)1 IntegrationRestException (com.synopsys.integration.rest.exception.IntegrationRestException)1 IOException (java.io.IOException)1