[Rakefile] Fix rescue to capture the error in a local var