Class: Lutaml::Xml::Schema::Xsd::Errors::MessageBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/lutaml/xml/schema/xsd/errors/message_builder.rb

Overview

Builder for constructing detailed error messages

Examples:

Building an error message

builder = MessageBuilder.new(error)
message = builder.build

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error) ⇒ MessageBuilder

Initialize message builder

Parameters:



20
21
22
# File 'lib/lutaml/xml/schema/xsd/errors/message_builder.rb', line 20

def initialize(error)
  @error = error
end

Instance Attribute Details

#errorEnhancedError (readonly)

Returns The error to build message for.

Returns:



15
16
17
# File 'lib/lutaml/xml/schema/xsd/errors/message_builder.rb', line 15

def error
  @error
end

Instance Method Details

#buildString

Build complete error message

Returns:

  • (String)

    Formatted error message



27
28
29
30
31
32
33
34
# File 'lib/lutaml/xml/schema/xsd/errors/message_builder.rb', line 27

def build
  parts = []
  parts << header
  parts << context_details if @error.context && !@error.context.to_h.empty?
  parts << suggestions_section if @error.respond_to?(:suggestions) && @error.suggestions.any?
  parts << troubleshooting_section if @error.respond_to?(:troubleshooting_tips) && @error.troubleshooting_tips.any?
  parts.compact.join("\n\n")
end