Move exception handling to the rakefile