Class: Sparkql::ParserError

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error_hash = {}) ⇒ ParserError

Returns a new instance of ParserError.



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/sparkql/errors.rb', line 45

def initialize(error_hash={})
  @token = error_hash[:token]
  @token_index = error_hash[:token_index]
  @expression = error_hash[:expression]
  @message = error_hash[:message]
  @status = error_hash[:status]
  @recovered_as = error_hash[:recovered_as]
  @recovered_as = error_hash[:recovered_as]
  @sparkql = error_hash[:sparkql]
  @nested_errors = error_hash[:nested_errors]
  self.syntax= error_hash[:syntax] == false ? false : true
  self.constraint= error_hash[:constraint] == true
end

Instance Attribute Details

#constraint=(value) ⇒ Object (writeonly)

Sets the attribute constraint

Parameters:

  • value

    the value to set the attribute constraint to.



43
44
45
# File 'lib/sparkql/errors.rb', line 43

def constraint=(value)
  @constraint = value
end

#expressionObject

Returns the value of attribute expression.



41
42
43
# File 'lib/sparkql/errors.rb', line 41

def expression
  @expression
end

#messageObject

Returns the value of attribute message.



41
42
43
# File 'lib/sparkql/errors.rb', line 41

def message
  @message
end

#nested_errorsObject

Returns the value of attribute nested_errors.



41
42
43
# File 'lib/sparkql/errors.rb', line 41

def nested_errors
  @nested_errors
end

#recovered_asObject

Returns the value of attribute recovered_as.



41
42
43
# File 'lib/sparkql/errors.rb', line 41

def recovered_as
  @recovered_as
end

#sparkqlObject

Returns the value of attribute sparkql.



41
42
43
# File 'lib/sparkql/errors.rb', line 41

def sparkql
  @sparkql
end

#statusObject

Returns the value of attribute status.



41
42
43
# File 'lib/sparkql/errors.rb', line 41

def status
  @status
end

#syntax=(value) ⇒ Object (writeonly)

Sets the attribute syntax

Parameters:

  • value

    the value to set the attribute syntax to.



43
44
45
# File 'lib/sparkql/errors.rb', line 43

def syntax=(value)
  @syntax = value
end

#tokenObject

Returns the value of attribute token.



41
42
43
# File 'lib/sparkql/errors.rb', line 41

def token
  @token
end

#token_indexObject

Returns the value of attribute token_index.



41
42
43
# File 'lib/sparkql/errors.rb', line 41

def token_index
  @token_index
end

Instance Method Details

#constraint?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/sparkql/errors.rb', line 63

def constraint?
  @constraint
end

#syntax?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/sparkql/errors.rb', line 59

def syntax?
  @syntax
end

#to_sObject



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/sparkql/errors.rb', line 67

def to_s
  str = case @status
        # Do nothing. Dropping the expressions isn't special
        when :dropped then "Dropped: " 
        # Fatal errors cannot be recovered from, and should cause anaylisis or
        # compilation to stop.
        when :fatal then "Fatal: "
        # Recovered errors are those that are syntatically
        # or symantically incorrect, but are ones that we could "guess" at the
        # intention
        when :recovered then
          "Recovered as #{@recovered_as}: "
        else ""
        end
  str += "<#{@token}> in " unless @token.nil?
  str += "<#{@expression}>: #{@message}."
  str
end