Catching NonDeterministicException

I’ve been bitten a couple of times by making changes to a workflow that caused a NonDeterministicException. I have a use case where when this is thrown, I just want the workflow to fail, so that I can trigger a new workflow with the same inputs on the new version. Basically the desired behavior is when NonDeterministicException just give up on the workflow.

Is there a kosher way of doing this? For example, can I catch NonDeterministicException and just mark it as a NonRetryableException?

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

WorkflowImplementationOptions options =
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.