class Failbot::ExceptionFormat::Structured
A newer exception format , based on the one sentry uses. Aside from different names and locations for things, the notable difference from haystack is that backtrace data has more structure.
Constants
- EMPTY_ARRAY
- FURTHER_CAUSES_WERE_OMITTED
Public Class Methods
call(e)
click to toggle source
Format an exception.
# File lib/failbot/exception_format/structured.rb, line 14 def self.call(e) message = e.message.to_s class_name = e.class.to_s begin Failbot.backtrace_parser.call(e) rescue => ex message += "\nUnable to parse backtrace (#{ex.inspect})\nDon't put non-backtrace text in Exception#backtrace please!\nSo-called backtrace follows:\n#{e.backtrace.join("\n")}" class_name += " (backtrace failed to parse)" EMPTY_ARRAY end { "platform" => "ruby", "exception_detail" => exception_details(e), "ruby" => RUBY_DESCRIPTION, "created_at" => Time.now.utc.iso8601(6) } end
exception_classname_from_hash(hash)
click to toggle source
given a hash generated by this class, return the exception class name.
# File lib/failbot/exception_format/structured.rb, line 73 def self.exception_classname_from_hash(hash) hash.dig("exception_detail", 0, "type") end
exception_details(e)
click to toggle source
# File lib/failbot/exception_format/structured.rb, line 38 def self.exception_details(e) result = [] depth = 0 loop do message = e.message.to_s class_name = e.class.to_s stacktrace = begin Failbot.backtrace_parser.call(e) rescue => ex message += "\nUnable to parse backtrace (#{ex.inspect})\nDon't put non-backtrace text in Exception#backtrace please!\nSo-called backtrace follows:\n#{e.backtrace.join("\n")}" class_name += " (backtrace failed to parse)" EMPTY_ARRAY end result.unshift({ "type" => class_name, "value" => message, "stacktrace" => stacktrace }) depth += 1 break unless (e=e.cause) if depth > MAXIMUM_CAUSE_DEPTH result.unshift(FURTHER_CAUSES_WERE_OMITTED) break end end result end
exception_message_from_hash(hash)
click to toggle source
given a hash generated by this class, return the exception message.
# File lib/failbot/exception_format/structured.rb, line 68 def self.exception_message_from_hash(hash) hash.dig("exception_detail", 0, "value") end