Class: Herb::Errors::UnclosedOpenTagError

Inherits:
Error
  • Object
show all
Includes:
Colors
Defined in:
lib/herb/errors.rb,
sig/herb/errors.rbs,
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, #self?.bold, #self?.bright_magenta, #self?.cyan, #self?.dimmed, #self?.enabled?, #self?.fg, #self?.fg_bg, #self?.green, #self?.magenta, #self?.red, #self?.white, #self?.yellow, white, yellow

Methods inherited from Error

#class_name, #error_name, #to_json

Constructor Details

#initialize(type, location, message, tag_name) ⇒ UnclosedOpenTagError

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

Parameters:



751
752
753
754
# File 'lib/herb/errors.rb', line 751

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

Instance Attribute Details

#tag_nameHerb::Token? (readonly)

| tag_name: Herb::Token?, | }

Returns:



748
749
750
# File 'lib/herb/errors.rb', line 748

def tag_name
  @tag_name
end

Instance Method Details

#inspectString

: () -> String

Returns:

  • (String)


757
758
759
# File 'lib/herb/errors.rb', line 757

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

#to_hashserialized_unclosed_open_tag_error

: () -> serialized_unclosed_open_tag_error

Returns:

  • (serialized_unclosed_open_tag_error)


762
763
764
765
766
# File 'lib/herb/errors.rb', line 762

def to_hash
  super.merge(
    tag_name: tag_name
  ) #: Herb::serialized_unclosed_open_tag_error
end

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

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

Parameters:

  • indent: (Integer) (defaults to: 0)
  • depth: (Integer) (defaults to: 0)
  • depth_limit: (Integer) (defaults to: 25)

Returns:

  • (String)


769
770
771
772
773
774
775
776
777
778
779
780
# File 'lib/herb/errors.rb', line 769

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("└── tag_name: ")
  output += tag_name ? tag_name.tree_inspect : magenta("")
  output += "\n"
  output += %(\n)

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