Class: Herb::Errors::MissingAttributeValueError

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

Constant Summary

Constants included from Colors

Colors::CLEAR_SCREEN, Colors::HIDE_CURSOR, Colors::SHOW_CURSOR

Instance Attribute Summary collapse

Attributes inherited from Error

#location, #message, #type

Instance Method Summary collapse

Methods included from Colors

bold, bright_magenta, cyan, dimmed, enabled?, fg, fg_bg, green, magenta, red, white, yellow

Methods inherited from Error

#class_name, #error_name, #to_json

Constructor Details

#initialize(type, location, message, attribute_name) ⇒ MissingAttributeValueError

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



874
875
876
877
# File 'lib/herb/errors.rb', line 874

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

Instance Attribute Details

#attribute_nameObject (readonly)

| attribute_name: String?, | }



871
872
873
# File 'lib/herb/errors.rb', line 871

def attribute_name
  @attribute_name
end

Instance Method Details

#inspectObject

: () -> String



880
881
882
# File 'lib/herb/errors.rb', line 880

def inspect
  tree_inspect.rstrip.gsub(/\s+$/, "")
end

#to_hashObject

: () -> serialized_missing_attribute_value_error



885
886
887
888
889
# File 'lib/herb/errors.rb', line 885

def to_hash
  super.merge(
    attribute_name: attribute_name
  ) #: Herb::serialized_missing_attribute_value_error
end

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

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



892
893
894
895
896
897
898
899
900
901
# File 'lib/herb/errors.rb', line 892

def tree_inspect(indent: 0, depth: 0, depth_limit: 25)
  output = +""

  output += white("@ #{bold(red(error_name))} #{dimmed("(location: #{location&.tree_inspect})\n")}")
  output += white("├── message: #{green(message.inspect)}\n")
  output += white("└── attribute_name: #{green(attribute_name.inspect)}\n")
  output += %(\n)

  output.gsub(/^/, "    " * indent)
end