Class: Aidp::Harness::UI::ErrorFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/aidp/harness/ui/error_handler.rb

Overview

Formats error messages for display

Instance Method Summary collapse

Instance Method Details

#format_component_error(error, component_name = nil) ⇒ Object



110
111
112
113
114
# File 'lib/aidp/harness/ui/error_handler.rb', line 110

def format_component_error(error, component_name = nil)
  base_message = "Component error"
  component_suffix = component_name ? " in #{component_name}" : ""
  "#{base_message}#{component_suffix}: #{error.message}"
end

#format_display_error(error, component_name = nil) ⇒ Object



98
99
100
101
102
# File 'lib/aidp/harness/ui/error_handler.rb', line 98

def format_display_error(error, component_name = nil)
  base_message = "Display error"
  component_suffix = component_name ? " in #{component_name}" : ""
  "#{base_message}#{component_suffix}: #{error.message}"
end

#format_generic_error(error) ⇒ Object



116
117
118
# File 'lib/aidp/harness/ui/error_handler.rb', line 116

def format_generic_error(error)
  "An unexpected error occurred: #{error.message}"
end

#format_interaction_error(error, interaction_type = nil) ⇒ Object



104
105
106
107
108
# File 'lib/aidp/harness/ui/error_handler.rb', line 104

def format_interaction_error(error, interaction_type = nil)
  base_message = "Interaction error"
  type_suffix = interaction_type ? " during #{interaction_type}" : ""
  "#{base_message}#{type_suffix}: #{error.message}"
end

#format_recovery_suggestion(error_type) ⇒ Object



120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/aidp/harness/ui/error_handler.rb', line 120

def format_recovery_suggestion(error_type)
  case error_type
  when :validation
    "Please check your input and try again."
  when :display
    "The display may not render correctly. Please try again."
  when :interaction
    "Please try the interaction again."
  when :component
    "The component may not function properly. Please restart the application."
  else
    "Please try again or restart the application if the problem persists."
  end
end

#format_validation_error(error, field_name = nil) ⇒ Object



92
93
94
95
96
# File 'lib/aidp/harness/ui/error_handler.rb', line 92

def format_validation_error(error, field_name = nil)
  base_message = "Validation failed"
  field_suffix = field_name ? " for #{field_name}" : ""
  "#{base_message}#{field_suffix}: #{error.message}"
end