Improve handling of errors in file staging.