Catching NonDeterministicException

NonDeterministicException cannot be caught inside your workflow code, but
you could set it to fail workflow execution via WorkflowImplementationOptions, for example:

WorkflowImplementationOptions options =
                WorkflowImplementationOptions.newBuilder()
                        .setFailWorkflowExceptionTypes(NonDeterministicException.class)
                        .build();
worker.registerWorkflowImplementationTypes(options, MyWorkflowImpl.class);

This should fail your workflow in case of NonDeterministicException.
Imo still the default behavior of blocking workflow task allowing you to fix the issue (using versioning for example) might be a better approach than failing the workflow execution.

1 Like