Take a specific outgoing sequenceflow in flowable 6

I am upgrading an app from 5.22 to 6.7.2 the app has several custom activities that use the concept of an optional error transition. That is, if an error occurs during the activity the execution should take a specific outgoing sequence flow otherwise it should take any flow other than the specific “error” flow.
in flowable 5 the code used

PvmTransition transition = execution.getActivity().findOutgoingTransition(errorTransition);

what would be the equivalent in version 6?
My initial thought was to manipulate the condition expression on each flow and call leave(). However I am not comfortable manipulating the process as it is defined.

You can use org.flowable.engine.delegate.DelegateHelper#leaveDelegate(execution, sequenceFlowId)

Thanks Joram,
I am getting there