Exception: Slaw::Parse::ParseError

Inherits:
Exception
  • Object
show all
Defined in:
lib/slaw/parse/error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, opts) ⇒ ParseError

Returns a new instance of ParseError.



6
7
8
9
10
11
# File 'lib/slaw/parse/error.rb', line 6

def initialize(message, opts)
  super(message)

  self.line = opts[:line]
  self.column = opts[:column]
end

Instance Attribute Details

#columnObject

Returns the value of attribute column.



4
5
6
# File 'lib/slaw/parse/error.rb', line 4

def column
  @column
end

#lineObject

Returns the value of attribute line.



4
5
6
# File 'lib/slaw/parse/error.rb', line 4

def line
  @line
end

Instance Method Details

#to_json(g = nil) ⇒ Object

TODO: move this elsewhere, it’s out of context here



14
15
16
17
18
19
20
21
22
23
# File 'lib/slaw/parse/error.rb', line 14

def to_json(g=nil)
  msg = self.message
  msg = msg[0..200] + '...' if msg.length > 200

  {
    message: msg,
    line: self.line,
    column: self.column,
  }.to_json(g)
end