refactoring #3159: file copy exception handling

* as discussed on github for #3159