Class: Herb::Errors::RenderMissingLocalsError

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, partial, keywords) ⇒ RenderMissingLocalsError

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

Parameters:

  • (String)
  • (Location, nil)
  • (String)
  • (String)
  • (String)


1066
1067
1068
1069
1070
# File 'lib/herb/errors.rb', line 1066

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

Instance Attribute Details

#keywordsString? (readonly)

: String?

Returns:

  • (String, nil)


1063
1064
1065
# File 'lib/herb/errors.rb', line 1063

def keywords
  @keywords
end

#partialString? (readonly)

| partial: String?, | keywords: String?, | }

Returns:

  • (String, nil)


1062
1063
1064
# File 'lib/herb/errors.rb', line 1062

def partial
  @partial
end

Instance Method Details

#inspectString

: () -> String

Returns:

  • (String)


1073
1074
1075
# File 'lib/herb/errors.rb', line 1073

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

#to_hashserialized_render_missing_locals_error

: () -> serialized_render_missing_locals_error

Returns:

  • (serialized_render_missing_locals_error)


1078
1079
1080
1081
1082
1083
# File 'lib/herb/errors.rb', line 1078

def to_hash
  super.merge(
    partial: partial,
    keywords: keywords
  ) #: Herb::serialized_render_missing_locals_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)


1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
# File 'lib/herb/errors.rb', line 1086

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("├── partial: #{green(partial.inspect)}\n")
  output += white("└── keywords: #{green(keywords.inspect)}\n")
  output += %(\n)

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