Class: Herb::Errors::Error

Inherits:
Object
  • Object
show all
Defined in:
lib/herb/errors.rb,
ext/herb/error_helpers.c

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, location, message) ⇒ Error

: (String, Location?, String) -> void



20
21
22
23
24
# File 'lib/herb/errors.rb', line 20

def initialize(type, location, message)
  @type = type
  @location = location
  @message = message
end

Instance Attribute Details

#locationObject (readonly)

: Location?



16
17
18
# File 'lib/herb/errors.rb', line 16

def location
  @location
end

#messageObject (readonly)

: String



17
18
19
# File 'lib/herb/errors.rb', line 17

def message
  @message
end

#typeObject (readonly)

: String



15
16
17
# File 'lib/herb/errors.rb', line 15

def type
  @type
end

Instance Method Details

#class_nameObject

: () -> String



36
37
38
# File 'lib/herb/errors.rb', line 36

def class_name
  self.class.name || "Error"
end

#error_nameObject

: () -> String



41
42
43
# File 'lib/herb/errors.rb', line 41

def error_name
  class_name.split("::").last || "Error"
end

#to_hashObject

: () -> serialized_error



27
28
29
30
31
32
33
# File 'lib/herb/errors.rb', line 27

def to_hash
  {
    type: type,
    location: location&.to_hash,
    message: message,
  }
end

#to_json(state = nil) ⇒ Object

: (?untyped) -> String



46
47
48
# File 'lib/herb/errors.rb', line 46

def to_json(state = nil)
  to_hash.to_json(state)
end

#tree_inspect(indent: 0, depth: 0, depth_limit: 25) ⇒ Object

: (?indent: Integer, ?depth: Integer, ?depth_limit: Integer) -> String

Raises:

  • (NotImplementedError)


51
52
53
# File 'lib/herb/errors.rb', line 51

def tree_inspect(indent: 0, depth: 0, depth_limit: 25)
  raise NotImplementedError
end