Delete file on error

There is a possibility to have both 'on error' and 'on end' ?