Skip to content

Instantly share code, notes, and snippets.

@yuroyoro
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save yuroyoro/9223947 to your computer and use it in GitHub Desktop.

Select an option

Save yuroyoro/9223947 to your computer and use it in GitHub Desktop.
print exception.backtrace.join("\n")と書くのに疲れた人へ
# -*- 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