Method: Bio::MAF::MAFParsing#parse_error

Defined in:
lib/bio/maf/parser.rb

#parse_error(msg) ⇒ Object

Raise a ParseError, indicating position within the MAF file and the chunk as well as the text surrounding the current scanner position.

Parameters:

  • msg (String)

    the error message

Raises:



274
275
276
277
278
279
280
281
282
283
284
285
286
# File 'lib/bio/maf/parser.rb', line 274

def parse_error(msg)
  s_start = [s.pos - 10, 0].max
  s_end = [s.pos + 10, s.string.length].min
  if s_start > 0
    left = s.string[s_start..(s.pos - 1)]
  else
    left = ''
  end
  right = s.string[s.pos..s_end]
  extra = "pos #{s.pos} [#{chunk_start + s.pos}], last #{last_block_pos}"

  raise ParseError, "#{msg} at: '#{left}>><<#{right}' (#{extra})"
end