Exception: Ruby::Rego::Error

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

Overview

Base error for all Ruby::Rego exceptions.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, location: nil) ⇒ Error

Create a new error with optional location details.

Parameters:

  • message (String, nil) (defaults to: nil)

    error message

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

    source location



30
31
32
33
34
# File 'lib/ruby/rego/errors.rb', line 30

def initialize(message = nil, location: nil)
  @raw_message = message
  @location = location
  super(compose_message(message))
end

Instance Attribute Details

#locationLocation? (readonly)

Returns:



24
25
26
# File 'lib/ruby/rego/errors.rb', line 24

def location
  @location
end

Instance Method Details

#to_hHash{Symbol => Object}

Serialize the error to a hash.

Returns:

  • (Hash{Symbol => Object})


39
40
41
42
43
44
45
# File 'lib/ruby/rego/errors.rb', line 39

def to_h
  {
    message: raw_message,
    type: self.class.name,
    location: location&.to_s
  }
end