Exception: Lutaml::Xml::Schema::Xsd::Errors::EnhancedError
- Inherits:
-
StandardError
- Object
- StandardError
- Lutaml::Xml::Schema::Xsd::Errors::EnhancedError
- Defined in:
- lib/lutaml/xml/schema/xsd/errors/enhanced_error.rb
Overview
Base class for enhanced errors with rich contextual information
Class Attribute Summary collapse
-
.suggester_class ⇒ Class?
Get suggester class for this error type.
-
.troubleshooter_class ⇒ Class?
Get troubleshooter class for this error type.
Instance Attribute Summary collapse
-
#context ⇒ ErrorContext
readonly
Error context.
Class Method Summary collapse
-
.use_suggester(klass) ⇒ void
Register suggester for this error type.
-
.use_troubleshooter(klass) ⇒ void
Register troubleshooter for this error type.
Instance Method Summary collapse
-
#error_code ⇒ String
Get error code.
-
#initialize(message, context: {}) ⇒ EnhancedError
constructor
Initialize enhanced error.
-
#severity ⇒ Symbol
Get error severity.
-
#suggestions ⇒ Array<Suggestion>
Get error suggestions.
-
#to_detailed_message ⇒ String
Build detailed error message with context, suggestions, and tips.
-
#troubleshooting_tips ⇒ Array<String>
Get troubleshooting tips.
Constructor Details
#initialize(message, context: {}) ⇒ EnhancedError
Initialize enhanced error
36 37 38 39 40 41 |
# File 'lib/lutaml/xml/schema/xsd/errors/enhanced_error.rb', line 36 def initialize(, context: {}) super() @context = context.is_a?(ErrorContext) ? context : ErrorContext.new(context) @suggester = nil @troubleshooter = nil end |
Class Attribute Details
.suggester_class ⇒ Class?
Get suggester class for this error type
106 107 108 |
# File 'lib/lutaml/xml/schema/xsd/errors/enhanced_error.rb', line 106 def suggester_class @suggester_class end |
.troubleshooter_class ⇒ Class?
Get troubleshooter class for this error type
115 116 117 |
# File 'lib/lutaml/xml/schema/xsd/errors/enhanced_error.rb', line 115 def troubleshooter_class @troubleshooter_class end |
Instance Attribute Details
#context ⇒ ErrorContext (readonly)
Returns Error context.
30 31 32 |
# File 'lib/lutaml/xml/schema/xsd/errors/enhanced_error.rb', line 30 def context @context end |
Class Method Details
.use_suggester(klass) ⇒ void
This method returns an undefined value.
Register suggester for this error type
125 126 127 |
# File 'lib/lutaml/xml/schema/xsd/errors/enhanced_error.rb', line 125 def use_suggester(klass) self.suggester_class = klass end |
.use_troubleshooter(klass) ⇒ void
This method returns an undefined value.
Register troubleshooter for this error type
133 134 135 |
# File 'lib/lutaml/xml/schema/xsd/errors/enhanced_error.rb', line 133 def use_troubleshooter(klass) self.troubleshooter_class = klass end |
Instance Method Details
#error_code ⇒ String
Get error code
71 72 73 |
# File 'lib/lutaml/xml/schema/xsd/errors/enhanced_error.rb', line 71 def error_code "E000" end |
#severity ⇒ Symbol
Get error severity
78 79 80 |
# File 'lib/lutaml/xml/schema/xsd/errors/enhanced_error.rb', line 78 def severity :error end |
#suggestions ⇒ Array<Suggestion>
Get error suggestions
46 47 48 49 50 |
# File 'lib/lutaml/xml/schema/xsd/errors/enhanced_error.rb', line 46 def suggestions return [] unless suggester @suggestions ||= suggester.generate_suggestions(self) end |
#to_detailed_message ⇒ String
Build detailed error message with context, suggestions, and tips
64 65 66 |
# File 'lib/lutaml/xml/schema/xsd/errors/enhanced_error.rb', line 64 def MessageBuilder.new(self).build end |
#troubleshooting_tips ⇒ Array<String>
Get troubleshooting tips
55 56 57 58 59 |
# File 'lib/lutaml/xml/schema/xsd/errors/enhanced_error.rb', line 55 def troubleshooting_tips return [] unless troubleshooter @troubleshooting_tips ||= troubleshooter.generate_tips(self) end |