Search in sources :

Example 1 with BinaryScanOutput

use of com.synopsys.integration.blackduck.codelocation.binaryscanner.BinaryScanOutput in project synopsys-detect by blackducksoftware.

the class BinaryUploadOperation method throwExceptionForError.

// BinaryScanBatchOutput used to do this, but our understanding of what needs to happen has been
// changing rapidly. Once we're confident we know what it should do, it should presumably move back there.
private void throwExceptionForError(BinaryScanBatchOutput binaryScanBatchOutput) throws BlackDuckIntegrationException {
    for (BinaryScanOutput binaryScanOutput : binaryScanBatchOutput) {
        if (binaryScanOutput.getResult() == Result.FAILURE) {
            // Black Duck responses are single-line message (loggable as-is), but nginx Bad Gateway responses are
            // multi-line html with the message embedded (that mess up the log).
            // cleanResponse() attempts to produce something reasonable to log in either case
            String cleanedBlackDuckResponse = cleanResponse(binaryScanOutput.getResponse());
            String uploadErrorMessage = String.format("Error when uploading binary scan: %s (Black Duck response: %s)", binaryScanOutput.getErrorMessage().orElse(binaryScanOutput.getStatusMessage()), cleanedBlackDuckResponse);
            logger.error(uploadErrorMessage);
            throw new BlackDuckIntegrationException(uploadErrorMessage);
        }
    }
}
Also used : BinaryScanOutput(com.synopsys.integration.blackduck.codelocation.binaryscanner.BinaryScanOutput) BlackDuckIntegrationException(com.synopsys.integration.blackduck.exception.BlackDuckIntegrationException)

Aggregations

BinaryScanOutput (com.synopsys.integration.blackduck.codelocation.binaryscanner.BinaryScanOutput)1 BlackDuckIntegrationException (com.synopsys.integration.blackduck.exception.BlackDuckIntegrationException)1