Last active
August 29, 2015 13:56
-
-
Save yuroyoro/9223947 to your computer and use it in GitHub Desktop.
print exception.backtrace.join("\n")と書くのに疲れた人へ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- encoding : utf-8 -*- | |
| class Exception | |
| def print_backtrace(options = {:out => $stderr, :filters => []}) | |
| out = options[:out] || $stderr | |
| filters = options[:filters] | |
| filters = filters.nil? ? [] : | |
| filters.respond_to?(:to_ary) ? filters.to_ary : | |
| [filters] | |
| traces = backtrace.to_a.reject{|line| filters.any?{|pattern| line.match(pattern)}} | |
| out.print "%s\n\n%s" % [self.to_s, traces.join("\n ")] | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment