RetryOptions.DoNotRetry vs ApplicationFailure.newNonRetryableFailure

Hi Temporal Team,
We want to simplify and standardize our codes.

RetryOptions.DoNotRetry and ApplicationFailure.newNonRetryableFailure
Both will be able to throw non-retryable failure.

But is there any reason we need to use DoNotRetry, as ApplicationFailure.newNonRetryableFailure already provided a standard way of handling non-retryable failure, while in DoNotRetry we need to maintain a separate config for exception list.

So we can have a errorcode constant together with ApplicationFailure.newNonRetryableFailure and don’t use RetryOptions.DoNotRetry at all?

In the case when an activity owns a definition of what’s retryable and what’s not, the ApplicationFailure.newNonRetryableFailure is the way to go. In the cases when an activity implementation is not owned by the workflow writer or is shared by many workflows, using RetryOptions.DoNotRetry is needed.