Exception: Yay::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/yay/errors.rb

Overview

the base class for errors in yay. this provides error reporting in a friendly way (who likes stack traces?)

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#positionObject (readonly)

Returns the value of attribute position.



6
7
8
# File 'lib/yay/errors.rb', line 6

def position
  @position
end

Instance Method Details

#printable_messageObject

override this to provide user feedback



9
10
11
# File 'lib/yay/errors.rb', line 9

def printable_message
  raise "Unimplemented printable error"
end

#printable_positionObject

a generic representation of the error’s location on the line, file, etc



14
15
16
17
18
19
20
21
# File 'lib/yay/errors.rb', line 14

def printable_position
  array  = @position
  return "" unless @position
  return " in file #{array[2]}, line #{array[1]}, word #{array[0]}" if array[2]
  return " on line #{array[1]}, word #{array[0]}" if array[1]
  return " at word #{array[0]}" if array[0]
  raise "junk position given to exception"
end