Class: Herb::Errors::RenderConflictingPartialError

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, positional_partial, keyword_partial) ⇒ RenderConflictingPartialError

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



1130
1131
1132
1133
1134
# File 'lib/herb/errors.rb', line 1130

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

Instance Attribute Details

#keyword_partialObject (readonly)

: String?



1127
1128
1129
# File 'lib/herb/errors.rb', line 1127

def keyword_partial
  @keyword_partial
end

#positional_partialObject (readonly)

| positional_partial: String?, | keyword_partial: String?, | }



1126
1127
1128
# File 'lib/herb/errors.rb', line 1126

def positional_partial
  @positional_partial
end

Instance Method Details

#inspectObject

: () -> String



1137
1138
1139
# File 'lib/herb/errors.rb', line 1137

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

#to_hashObject

: () -> serialized_render_conflicting_partial_error



1142
1143
1144
1145
1146
1147
# File 'lib/herb/errors.rb', line 1142

def to_hash
  super.merge(
    positional_partial: positional_partial,
    keyword_partial: keyword_partial
  ) #: Herb::serialized_render_conflicting_partial_error
end

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

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



1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
# File 'lib/herb/errors.rb', line 1150

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

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