Never rescue ::Exception, it masks all kinds of things that you don't expect, like syntax errors.  You probably want something like:
```ruby
begin
  session.fs.file.upload_file(file_on_target, file)
rescue ::Rex::Post::Meterpreter::RequestError => e
  fail_with(Failure::NotFound, e.message)
end
```