Class: Herb::Errors::RenderLayoutWithoutBlockError

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, layout) ⇒ RenderLayoutWithoutBlockError

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



1231
1232
1233
1234
# File 'lib/herb/errors.rb', line 1231

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

Instance Attribute Details

#layoutObject (readonly)

| layout: String?, | }



1228
1229
1230
# File 'lib/herb/errors.rb', line 1228

def layout
  @layout
end

Instance Method Details

#inspectObject

: () -> String



1237
1238
1239
# File 'lib/herb/errors.rb', line 1237

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

#to_hashObject

: () -> serialized_render_layout_without_block_error



1242
1243
1244
1245
1246
# File 'lib/herb/errors.rb', line 1242

def to_hash
  super.merge(
    layout: layout
  ) #: Herb::serialized_render_layout_without_block_error
end

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

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



1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
# File 'lib/herb/errors.rb', line 1249

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

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