Class: Yeller::ExceptionFormatter
- Inherits:
-
Object
- Object
- Yeller::ExceptionFormatter
- Defined in:
- lib/yeller/exception_formatter.rb
Defined Under Namespace
Classes: IdentityBacktraceFilter
Constant Summary collapse
- BACKTRACE_FORMAT =
%r{^((?:[a-zA-Z]:)?[^:]+):(\d+)(?::in `([^']+)')?$}.freeze
Instance Attribute Summary collapse
-
#backtrace_filter ⇒ Object
readonly
Returns the value of attribute backtrace_filter.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #formatted_backtrace ⇒ Object
-
#initialize(exception, backtrace_filter, options) ⇒ ExceptionFormatter
constructor
A new instance of ExceptionFormatter.
- #message ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(exception, backtrace_filter, options) ⇒ ExceptionFormatter
Returns a new instance of ExceptionFormatter.
18 19 20 21 22 23 24 25 |
# File 'lib/yeller/exception_formatter.rb', line 18 def initialize(exception, backtrace_filter, ) @type = exception.class.name = exception. @backtrace = exception.backtrace = @backtrace_filter = backtrace_filter end |
Instance Attribute Details
#backtrace_filter ⇒ Object (readonly)
Returns the value of attribute backtrace_filter.
16 17 18 |
# File 'lib/yeller/exception_formatter.rb', line 16 def backtrace_filter @backtrace_filter end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
16 17 18 |
# File 'lib/yeller/exception_formatter.rb', line 16 def end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
16 17 18 |
# File 'lib/yeller/exception_formatter.rb', line 16 def type @type end |
Class Method Details
.format(exception, backtrace_filter = IdentityBacktraceFilter.new, options = {}) ⇒ Object
12 13 14 |
# File 'lib/yeller/exception_formatter.rb', line 12 def self.format(exception, backtrace_filter=IdentityBacktraceFilter.new, ={}) new(exception, backtrace_filter, ).to_hash end |
Instance Method Details
#formatted_backtrace ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/yeller/exception_formatter.rb', line 32 def formatted_backtrace return [] unless @backtrace original_trace = @backtrace.map do |line| _, file, number, method = line.match(BACKTRACE_FORMAT).to_a [file, number, method] end backtrace_filter.filter(original_trace) end |
#message ⇒ Object
27 28 29 30 |
# File 'lib/yeller/exception_formatter.rb', line 27 def # If a message is not given, rubby will set message to the class name == type ? nil : end |
#to_hash ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/yeller/exception_formatter.rb', line 42 def to_hash result = { :message => , :stacktrace => formatted_backtrace, :type => type, :"custom-data" => .fetch(:custom_data, {}) } result[:url] = [:url] if .key?(:url) result[:location] = [:location] if .key?(:location) result end |