Class: Monolith::ExceptionsController::ExceptionInfo
- Inherits:
-
Object
- Object
- Monolith::ExceptionsController::ExceptionInfo
- Defined in:
- app/controllers/monolith/exceptions_controller.rb
Overview
Inline ActiveModel-like object
Instance Attribute Summary collapse
-
#exception ⇒ Object
readonly
Returns the value of attribute exception.
Instance Method Summary collapse
- #backtrace ⇒ Object
- #class_name ⇒ Object
- #first_application_frame ⇒ Object
- #grouped_trace ⇒ Object
-
#initialize(exception) ⇒ ExceptionInfo
constructor
A new instance of ExceptionInfo.
- #message ⇒ Object
- #source_extract ⇒ Object
Constructor Details
#initialize(exception) ⇒ ExceptionInfo
Returns a new instance of ExceptionInfo.
65 66 67 |
# File 'app/controllers/monolith/exceptions_controller.rb', line 65 def initialize(exception) @exception = exception end |
Instance Attribute Details
#exception ⇒ Object (readonly)
Returns the value of attribute exception.
63 64 65 |
# File 'app/controllers/monolith/exceptions_controller.rb', line 63 def exception @exception end |
Instance Method Details
#backtrace ⇒ Object
77 78 79 |
# File 'app/controllers/monolith/exceptions_controller.rb', line 77 def backtrace exception.backtrace || [] end |
#class_name ⇒ Object
69 70 71 |
# File 'app/controllers/monolith/exceptions_controller.rb', line 69 def class_name exception.class.name end |
#first_application_frame ⇒ Object
95 96 97 98 |
# File 'app/controllers/monolith/exceptions_controller.rb', line 95 def first_application_frame # Try Application first, then any other group grouped_trace.find { |f| f[:group] == 'Application' } || grouped_trace.first end |
#grouped_trace ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'app/controllers/monolith/exceptions_controller.rb', line 81 def grouped_trace @grouped_trace ||= backtrace.map do |frame| file, line, method = parse_frame(frame) group = categorize_frame(frame) { frame: frame, file: file, line: line, method: method, group: group } end end |
#message ⇒ Object
73 74 75 |
# File 'app/controllers/monolith/exceptions_controller.rb', line 73 def exception. end |
#source_extract ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 |
# File 'app/controllers/monolith/exceptions_controller.rb', line 100 def source_extract frame = first_application_frame return nil unless frame file = frame[:file] line = frame[:line] return nil unless file && line return nil unless File.exist?(file) extract_source(file, line) end |