Class: Herb::Errors::StrictLocalsPositionalArgumentError

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

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



1270
1271
1272
1273
# File 'lib/herb/errors.rb', line 1270

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

Instance Attribute Details

#nameObject (readonly)

| name: String?, | }



1267
1268
1269
# File 'lib/herb/errors.rb', line 1267

def name
  @name
end

Instance Method Details

#inspectObject

: () -> String



1276
1277
1278
# File 'lib/herb/errors.rb', line 1276

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

#to_hashObject

: () -> serialized_strict_locals_positional_argument_error



1281
1282
1283
1284
1285
# File 'lib/herb/errors.rb', line 1281

def to_hash
  super.merge(
    name: name
  ) #: Herb::serialized_strict_locals_positional_argument_error
end

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

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



1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
# File 'lib/herb/errors.rb', line 1288

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