Class: Herb::Errors::StrictLocalsBlockArgumentError

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, name) ⇒ StrictLocalsBlockArgumentError

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

Parameters:

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


1309
1310
1311
1312
# File 'lib/herb/errors.rb', line 1309

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

Instance Attribute Details

#nameString? (readonly)

| name: String?, | }

Returns:

  • (String, nil)


1306
1307
1308
# File 'lib/herb/errors.rb', line 1306

def name
  @name
end

Instance Method Details

#inspectString

: () -> String

Returns:

  • (String)


1315
1316
1317
# File 'lib/herb/errors.rb', line 1315

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

#to_hashserialized_strict_locals_block_argument_error

: () -> serialized_strict_locals_block_argument_error

Returns:

  • (serialized_strict_locals_block_argument_error)


1320
1321
1322
1323
1324
# File 'lib/herb/errors.rb', line 1320

def to_hash
  super.merge(
    name: name
  ) #: Herb::serialized_strict_locals_block_argument_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)


1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
# File 'lib/herb/errors.rb', line 1327

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

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