# File lib/rake.rb, line 2035
2035:     def standard_exception_handling
2036:       begin
2037:         yield
2038:       rescue SystemExit => ex
2039:         # Exit silently with current status
2040:         exit(ex.status)
2041:       rescue SystemExit, OptionParser::InvalidOption => ex
2042:         # Exit silently
2043:         exit(1)
2044:       rescue Exception => ex
2045:         # Exit with error message
2046:         $stderr.puts "rake aborted!"
2047:         $stderr.puts ex.message
2048:         if options.trace
2049:           $stderr.puts ex.backtrace.join("\n")
2050:         else
2051:           $stderr.puts ex.backtrace.find {|str| str =~ /#{@rakefile}/ } || ""
2052:           $stderr.puts "(See full trace by running task with --trace)"
2053:         end
2054:         exit(1)
2055:       end
2056:     end