Exception: Ruby::Rego::UnificationError

Inherits:
Error
  • Object
show all
Defined in:
lib/ruby/rego/errors.rb

Overview

Error raised during unification/pattern matching.

Instance Attribute Summary collapse

Attributes inherited from Error

#location

Instance Method Summary collapse

Methods inherited from Error

#to_h

Constructor Details

#initialize(message, pattern: nil, value: nil, location: nil) ⇒ UnificationError

Create a unification error.

Parameters:

  • message (String)

    error message

  • pattern (Object, nil) (defaults to: nil)

    pattern being matched

  • value (Object, nil) (defaults to: nil)

    value being matched

  • location (Location, nil) (defaults to: nil)

    source location



187
188
189
190
191
192
193
# File 'lib/ruby/rego/errors.rb', line 187

def initialize(message, pattern: nil, value: nil, location: nil)
  @pattern = pattern
  @value = value
  details = ErrorFormatting.format_details(pattern: pattern, value: value)
  composed = details.empty? ? message : "#{message} (#{details})"
  super(composed, location: location)
end

Instance Attribute Details

#patternObject? (readonly)

Returns:

  • (Object, nil)


176
177
178
# File 'lib/ruby/rego/errors.rb', line 176

def pattern
  @pattern
end

#valueObject? (readonly)

Returns:

  • (Object, nil)


179
180
181
# File 'lib/ruby/rego/errors.rb', line 179

def value
  @value
end