Exception: Kapusta::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Kapusta::Error
- Defined in:
- lib/kapusta/error.rb
Direct Known Subclasses
Compiler::Error, Compiler::MacroExpander::Error, Formatter::Error, Reader::Error
Instance Attribute Summary collapse
-
#column ⇒ Object
readonly
Returns the value of attribute column.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#reason ⇒ Object
readonly
Returns the value of attribute reason.
Instance Method Summary collapse
- #formatted ⇒ Object
-
#initialize(reason, path: nil, line: nil, column: nil) ⇒ Error
constructor
A new instance of Error.
- #with_defaults(path: nil, line: nil, column: nil) ⇒ Object
Constructor Details
#initialize(reason, path: nil, line: nil, column: nil) ⇒ Error
Returns a new instance of Error.
7 8 9 10 11 12 13 |
# File 'lib/kapusta/error.rb', line 7 def initialize(reason, path: nil, line: nil, column: nil) @reason = reason @path = path @line = line @column = column super(formatted) end |
Instance Attribute Details
#column ⇒ Object (readonly)
Returns the value of attribute column.
5 6 7 |
# File 'lib/kapusta/error.rb', line 5 def column @column end |
#line ⇒ Object (readonly)
Returns the value of attribute line.
5 6 7 |
# File 'lib/kapusta/error.rb', line 5 def line @line end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/kapusta/error.rb', line 5 def path @path end |
#reason ⇒ Object (readonly)
Returns the value of attribute reason.
5 6 7 |
# File 'lib/kapusta/error.rb', line 5 def reason @reason end |
Instance Method Details
#formatted ⇒ Object
15 16 17 18 |
# File 'lib/kapusta/error.rb', line 15 def formatted prefix = [path, line, column].compact.join(':') prefix.empty? ? reason : "#{prefix}: #{reason}" end |
#with_defaults(path: nil, line: nil, column: nil) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/kapusta/error.rb', line 20 def with_defaults(path: nil, line: nil, column: nil) copy = self.class.new(@reason, path: @path || path, line: @line || line, column: @column || column) copy.set_backtrace(backtrace) if backtrace copy end |