Exception: Cataract::ParseError
- Defined in:
- lib/cataract/error.rb,
ext/cataract/cataract.c
Overview
Error raised when invalid CSS is encountered in strict mode
Instance Attribute Summary collapse
-
#column ⇒ Object
readonly
Returns the value of attribute column.
-
#error_type ⇒ Object
readonly
Returns the value of attribute error_type.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
Instance Method Summary collapse
-
#initialize(message, css: nil, pos: nil, line: nil, column: nil, type: nil) ⇒ ParseError
constructor
A new instance of ParseError.
Constructor Details
#initialize(message, css: nil, pos: nil, line: nil, column: nil, type: nil) ⇒ ParseError
Returns a new instance of ParseError.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/cataract/error.rb', line 24 def initialize(, css: nil, pos: nil, line: nil, column: nil, type: nil) # Calculate line/column from css and pos if provided if css && pos @line = css.byteslice(0, pos).count("\n") + 1 line_start = css.rindex("\n", pos - 1) @column = line_start ? pos - line_start : pos + 1 else @line = line @column = column end @error_type = type # Build message with position info = if @line && @column "#{} at line #{@line}, column #{@column}" elsif @line "#{} at line #{@line}" else end super() end |
Instance Attribute Details
#column ⇒ Object (readonly)
Returns the value of attribute column.
16 17 18 |
# File 'lib/cataract/error.rb', line 16 def column @column end |
#error_type ⇒ Object (readonly)
Returns the value of attribute error_type.
16 17 18 |
# File 'lib/cataract/error.rb', line 16 def error_type @error_type end |
#line ⇒ Object (readonly)
Returns the value of attribute line.
16 17 18 |
# File 'lib/cataract/error.rb', line 16 def line @line end |