Manually cancel the node execution

Hi everyone

In my code sometimes I need to cancel the execution of a node manually, for example when the user closes a dialog pane or when certain requirements weren't satisfied. Currently I use the following code to do so, it works but gives two messages, one custom and one default (Execution canceled & Execution was canceled by user). That's why I wanted to check if this is the correct way of handling the cancel process. Is there a better way?

setWarningMessage("Execution was canceled by user");
exec.getProgressMonitor().setExecuteCanceled();
exec.checkCanceled();

Thx