Exception: Fyrehose::ProtocolError

Inherits:
Error
  • Object
show all
Defined in:
lib/fyrehose/errors.rb

Constant Summary collapse

INFO_SIZE =
30

Instance Method Summary collapse

Constructor Details

#initialize(buf = nil, pos = nil) ⇒ ProtocolError

Returns a new instance of ProtocolError.



9
10
11
12
13
14
15
# File 'lib/fyrehose/errors.rb', line 9

def initialize(buf=nil, pos=nil)
  return unless buf
  offset = [0, pos - (INFO_SIZE / 2)].max
  @info = "\n    => "
  @info << buf[offset..offset + INFO_SIZE].gsub("\n", " ")
  @info << "\n#{" " * (pos - offset + 7)}^\n"
end

Instance Method Details

#to_sObject



17
18
19
# File 'lib/fyrehose/errors.rb', line 17

def to_s
  "invalid token#{@info}"
end