Class: Lutaml::Xsd::Errors::ErrorContext
- Inherits:
-
Object
- Object
- Lutaml::Xsd::Errors::ErrorContext
- Defined in:
- lib/lutaml/xsd/errors/error_context.rb
Overview
Value object representing contextual information for enhanced errors
Instance Attribute Summary collapse
-
#actual_value ⇒ String?
readonly
Actual value that caused the error.
-
#additional ⇒ Hash
readonly
Additional context attributes.
-
#expected_type ⇒ String?
readonly
Expected type name.
-
#location ⇒ String?
readonly
XPath location of the error.
-
#namespace ⇒ String?
readonly
Namespace URI.
-
#repository ⇒ Lutaml::Xsd::SchemaRepository?
readonly
Schema repository for suggestions.
Instance Method Summary collapse
-
#has_repository? ⇒ Boolean
Check if context has repository for suggestions.
-
#initialize(attrs = {}) ⇒ ErrorContext
constructor
Initialize error context with attributes.
-
#to_h ⇒ Hash
Convert context to hash representation.
Constructor Details
#initialize(attrs = {}) ⇒ ErrorContext
Initialize error context with attributes
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/lutaml/xsd/errors/error_context.rb', line 42 def initialize(attrs = {}) @location = attrs[:location] @namespace = attrs[:namespace] @expected_type = attrs[:expected_type] @actual_value = attrs[:actual_value] @repository = attrs[:repository] @additional = attrs.except( :location, :namespace, :expected_type, :actual_value, :repository ) end |
Instance Attribute Details
#actual_value ⇒ String? (readonly)
Returns Actual value that caused the error.
26 27 28 |
# File 'lib/lutaml/xsd/errors/error_context.rb', line 26 def actual_value @actual_value end |
#additional ⇒ Hash (readonly)
Returns Additional context attributes.
32 33 34 |
# File 'lib/lutaml/xsd/errors/error_context.rb', line 32 def additional @additional end |
#expected_type ⇒ String? (readonly)
Returns Expected type name.
23 24 25 |
# File 'lib/lutaml/xsd/errors/error_context.rb', line 23 def expected_type @expected_type end |
#location ⇒ String? (readonly)
Returns XPath location of the error.
17 18 19 |
# File 'lib/lutaml/xsd/errors/error_context.rb', line 17 def location @location end |
#namespace ⇒ String? (readonly)
Returns Namespace URI.
20 21 22 |
# File 'lib/lutaml/xsd/errors/error_context.rb', line 20 def namespace @namespace end |
#repository ⇒ Lutaml::Xsd::SchemaRepository? (readonly)
Returns Schema repository for suggestions.
29 30 31 |
# File 'lib/lutaml/xsd/errors/error_context.rb', line 29 def repository @repository end |
Instance Method Details
#has_repository? ⇒ Boolean
Check if context has repository for suggestions
69 70 71 |
# File 'lib/lutaml/xsd/errors/error_context.rb', line 69 def has_repository? !@repository.nil? end |
#to_h ⇒ Hash
Convert context to hash representation
57 58 59 60 61 62 63 64 |
# File 'lib/lutaml/xsd/errors/error_context.rb', line 57 def to_h { location: @location, namespace: @namespace, expected_type: @expected_type, actual_value: @actual_value, }.merge(@additional).compact end |