void throwActivityFailureException()

in src/main/java/com/amazonaws/services/simpleworkflow/flow/pojo/POJOActivityImplementation.java [104:139]


    void throwActivityFailureException(Throwable exception) throws ActivityFailureException, CancellationException {

        if (exception instanceof CancellationException) {
            throw (CancellationException) exception;
        }

        String reason = exception.getMessage();
        String details = null;
        try {
            details = ThreadLocalMetrics.getMetrics().recordSupplier(
                () -> converter.toData(exception),
                converter.getClass().getSimpleName() + "@" + MetricName.Operation.DATA_CONVERTER_SERIALIZE.getName(),
                TimeUnit.MILLISECONDS
            );
        }
        catch (DataConverterException dataConverterException) {
            if (dataConverterException.getCause() == null) {
                dataConverterException.initCause(exception);
            }
            throw dataConverterException;
        }

        if (details.length() > FlowValueConstraint.FAILURE_DETAILS.getMaxSize()) {
            log.warn("Length of details is over maximum input length of 32768. Actual details: " + details);
            Throwable truncatedException = WorkflowExecutionUtils.truncateStackTrace(exception);
            ThreadLocalMetrics.getMetrics().recordCount(MetricName.RESPONSE_TRUNCATED.getName(), 1,
                MetricName.getActivityTypeDimension(CurrentActivityExecutionContext.get().getTask().getActivityType()));
            details = ThreadLocalMetrics.getMetrics().recordSupplier(
                () -> converter.toData(truncatedException),
                converter.getClass().getSimpleName() + "@" + MetricName.Operation.DATA_CONVERTER_SERIALIZE.getName(),
                TimeUnit.MILLISECONDS
            );
        }

        throw new ActivityFailureException(reason, details);
    }