Class: ErrorReady::Formatter
- Inherits:
-
Object
- Object
- ErrorReady::Formatter
- Defined in:
- lib/error_ready/formatter.rb
Instance Method Summary collapse
- #format ⇒ Object
-
#initialize(error:, handled:, severity:, context:, source: nil) ⇒ Formatter
constructor
A new instance of Formatter.
- #wrapped_exception(error) ⇒ Object
Constructor Details
#initialize(error:, handled:, severity:, context:, source: nil) ⇒ Formatter
Returns a new instance of Formatter.
3 4 5 6 7 8 9 |
# File 'lib/error_ready/formatter.rb', line 3 def initialize(error:, handled:, severity:, context:, source: nil) @handled = handled @severity = severity @context = context @source = source @error = wrapped_exception(error) end |
Instance Method Details
#format ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/error_ready/formatter.rb', line 11 def format { message: @error.exception., err_class: @error.exception.class.to_s, severity: @severity.to_s, source: @source, environment: Rails.env, context: @context.transform_values(&:to_s), source_to_show: @error.source_extracts[@error.source_to_show_id], application_trace: @error.application_trace, full_trace: @error.full_trace } end |
#wrapped_exception(error) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/error_ready/formatter.rb', line 25 def wrapped_exception(error) ActionDispatch::ExceptionWrapper.new( Rails::BacktraceCleaner.new, error ) end |