class Rake::Application
def standard_exception_handling
def standard_exception_handling begin yield rescue SystemExit => ex # Exit silently with current status exit(ex.status) rescue SystemExit, GetoptLong::InvalidOption => ex # Exit silently exit(1) rescue Exception => ex # Exit with error message $stderr.puts "rake aborted!" $stderr.puts ex.message if options.trace $stderr.puts ex.backtrace.join("\n") else $stderr.puts ex.backtrace.find {|str| str =~ /#{@rakefile}/ } || "" $stderr.puts "(See full trace by running task with --trace)" end exit(1) end end