looking at https://github.com/saltstack/salt/blob/develop/salt/modules/file.py it appears salt does the latter: https://github.com/saltstack/salt/blob/develop/salt/modules/file.py

these exceptions look useful:
https://github.com/saltstack/salt/blob/develop/salt/exceptions.py#L46-L50
https://github.com/saltstack/salt/blob/develop/salt/exceptions.py#L65