Class: Herb::Errors::UnexpectedError
- 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
-
#description ⇒ Object
readonly
| description: String?, | expected: String?, | found: String?, | }.
-
#expected ⇒ Object
readonly
: String?.
-
#found ⇒ Object
readonly
: String?.
Attributes inherited from Error
Instance Method Summary collapse
-
#initialize(type, location, message, description, expected, found) ⇒ UnexpectedError
constructor
: (String, Location?, String, String, String, String) -> void.
-
#inspect ⇒ Object
: () -> String.
-
#to_hash ⇒ Object
: () -> serialized_unexpected_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, description, expected, found) ⇒ UnexpectedError
: (String, Location?, String, String, String, String) -> void
69 70 71 72 73 74 |
# File 'lib/herb/errors.rb', line 69 def initialize(type, location, , description, expected, found) super(type, location, ) @description = description @expected = expected @found = found end |
Instance Attribute Details
#description ⇒ Object (readonly)
| description: String?, | expected: String?, | found: String?, | }
64 65 66 |
# File 'lib/herb/errors.rb', line 64 def description @description end |
#expected ⇒ Object (readonly)
: String?
65 66 67 |
# File 'lib/herb/errors.rb', line 65 def expected @expected end |
#found ⇒ Object (readonly)
: String?
66 67 68 |
# File 'lib/herb/errors.rb', line 66 def found @found end |
Instance Method Details
#inspect ⇒ Object
: () -> String
77 78 79 |
# File 'lib/herb/errors.rb', line 77 def inspect tree_inspect.rstrip.gsub(/\s+$/, "") end |
#to_hash ⇒ Object
: () -> serialized_unexpected_error
82 83 84 85 86 87 88 |
# File 'lib/herb/errors.rb', line 82 def to_hash super.merge( description: description, expected: expected, found: found ) #: Herb::serialized_unexpected_error end |
#tree_inspect(indent: 0, depth: 0, depth_limit: 25) ⇒ Object
: (?indent: Integer, ?depth: Integer, ?depth_limit: Integer) -> String
91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/herb/errors.rb', line 91 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("├── description: #{green(description.inspect)}\n") output += white("├── expected: #{green(expected.inspect)}\n") output += white("└── found: #{green(found.inspect)}\n") output += %(\n) output.gsub(/^/, " " * indent) end |