I enclosed some code in a begin rescue end block:
begin
...
rescue StandardError => e
puts("Exception #{e} occurred")
puts("Copying script to error folder.")
FileUtils.cp("Demo.rb", "C:/Ruby/Failure")
end
I'm not sure how to execute a bit of code if no exceptions are thrown so I can copy my script to a success folder. Any help would be appreciated.
StandardErroris the default, you can just writerescue => e