Class: RailsErrorDashboard::Services::MarkdownErrorFormatter
- Inherits:
-
Object
- Object
- RailsErrorDashboard::Services::MarkdownErrorFormatter
- Defined in:
- lib/rails_error_dashboard/services/markdown_error_formatter.rb
Overview
Pure algorithm: Format error details as clean Markdown for LLM debugging
Reads data already stored in ErrorLog — zero runtime cost. Called at display time only. Sections are conditional — only included when data is present.
Constant Summary collapse
- MAX_BACKTRACE_LINES =
15- MAX_BREADCRUMBS =
10- MAX_VARIABLES =
10
Class Method Summary collapse
-
.call(error, related_errors: []) ⇒ String
Markdown-formatted error details, or “” on failure.
Instance Method Summary collapse
- #generate ⇒ String
-
#initialize(error, related_errors) ⇒ MarkdownErrorFormatter
constructor
A new instance of MarkdownErrorFormatter.
Constructor Details
#initialize(error, related_errors) ⇒ MarkdownErrorFormatter
Returns a new instance of MarkdownErrorFormatter.
28 29 30 31 |
# File 'lib/rails_error_dashboard/services/markdown_error_formatter.rb', line 28 def initialize(error, ) @error = error @related_errors = end |
Class Method Details
.call(error, related_errors: []) ⇒ String
Returns Markdown-formatted error details, or “” on failure.
22 23 24 25 26 |
# File 'lib/rails_error_dashboard/services/markdown_error_formatter.rb', line 22 def self.call(error, related_errors: []) new(error, ).generate rescue => e "" end |
Instance Method Details
#generate ⇒ String
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rails_error_dashboard/services/markdown_error_formatter.rb', line 34 def generate sections = [] sections << heading_section sections << backtrace_section sections << source_code_section sections << cause_chain_section sections << local_variables_section sections << instance_variables_section sections << request_context_section sections << sections << environment_section sections << system_health_section sections << sections << sections.compact.join("\n\n") rescue => e "" end |