There is the Failhard option for salt. If you use it as a global option, any failure within a state will terminate the execution of all following states. But you can also use it selectively.
Maybe you could add the Failhard option to your existing states.
If you want to have a specific error message, a 1:1 translation of your example could look like this:
SALTSTACK:
cmd.run:
- name: bash -c test -e /tmp/notexist || (echo "unable to find file" && exit 1)
- failhard: True
It will result in an output like this. The error message is at the end.
local:
----------
ID: SALTSTACK
Function: cmd.run
Name: bash -c test -e /tmp/notexist || (echo "unable to find file" && exit 1)
Result: False
Comment: Command "bash -c test -e /tmp/notexist || (echo "unable to find file" && exit 1)" run
Started: 21:30:34.473132
Duration: 7.353 ms
Changes:
----------
pid:
5499
retcode:
1
stderr:
stdout:
unable to find file