Class: Herb::Errors::RubyParseError
- 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
-
#diagnostic_id ⇒ Object
readonly
: String?.
-
#error_message ⇒ Object
readonly
| error_message: String?, | diagnostic_id: String?, | level: String?, | }.
-
#level ⇒ Object
readonly
: String?.
Attributes inherited from Error
Instance Method Summary collapse
-
#initialize(type, location, message, error_message, diagnostic_id, level) ⇒ RubyParseError
constructor
: (String, Location?, String, String, String, String) -> void.
-
#inspect ⇒ Object
: () -> String.
-
#to_hash ⇒ Object
: () -> serialized_ruby_parse_error.
-
#tree_inspect(indent: 0, depth: 0, depth_limit: 25) ⇒ Object
: (?indent: Integer, ?depth: Integer, ?depth_limit: Integer) -> String.
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, error_message, diagnostic_id, level) ⇒ RubyParseError
: (String, Location?, String, String, String, String) -> void
386 387 388 389 390 391 |
# File 'lib/herb/errors.rb', line 386 def initialize(type, location, , , diagnostic_id, level) super(type, location, ) @error_message = @diagnostic_id = diagnostic_id @level = level end |
Instance Attribute Details
#diagnostic_id ⇒ Object (readonly)
: String?
382 383 384 |
# File 'lib/herb/errors.rb', line 382 def diagnostic_id @diagnostic_id end |
#error_message ⇒ Object (readonly)
| error_message: String?, | diagnostic_id: String?, | level: String?, | }
381 382 383 |
# File 'lib/herb/errors.rb', line 381 def @error_message end |
#level ⇒ Object (readonly)
: String?
383 384 385 |
# File 'lib/herb/errors.rb', line 383 def level @level end |
Instance Method Details
#inspect ⇒ Object
: () -> String
394 395 396 |
# File 'lib/herb/errors.rb', line 394 def inspect tree_inspect.rstrip.gsub(/\s+$/, "") end |
#to_hash ⇒ Object
: () -> serialized_ruby_parse_error
399 400 401 402 403 404 405 |
# File 'lib/herb/errors.rb', line 399 def to_hash super.merge( error_message: , diagnostic_id: diagnostic_id, level: level ) #: Herb::serialized_ruby_parse_error end |
#tree_inspect(indent: 0, depth: 0, depth_limit: 25) ⇒ Object
: (?indent: Integer, ?depth: Integer, ?depth_limit: Integer) -> String
408 409 410 411 412 413 414 415 416 417 418 419 |
# File 'lib/herb/errors.rb', line 408 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(.inspect)}\n") output += white("├── error_message: #{green(.inspect)}\n") output += white("├── diagnostic_id: #{green(diagnostic_id.inspect)}\n") output += white("└── level: #{green(level.inspect)}\n") output += %(\n) output.gsub(/^/, " " * indent) end |