Class: Sparkql::ParserError
- Inherits:
-
Object
- Object
- Sparkql::ParserError
- Defined in:
- lib/sparkql/errors.rb
Instance Attribute Summary collapse
-
#constraint ⇒ Object
writeonly
Sets the attribute constraint.
-
#expression ⇒ Object
Returns the value of attribute expression.
-
#message ⇒ Object
Returns the value of attribute message.
-
#nested_errors ⇒ Object
Returns the value of attribute nested_errors.
-
#recovered_as ⇒ Object
Returns the value of attribute recovered_as.
-
#sparkql ⇒ Object
Returns the value of attribute sparkql.
-
#status ⇒ Object
Returns the value of attribute status.
-
#syntax ⇒ Object
writeonly
Sets the attribute syntax.
-
#token ⇒ Object
Returns the value of attribute token.
-
#token_index ⇒ Object
Returns the value of attribute token_index.
Instance Method Summary collapse
- #constraint? ⇒ Boolean
-
#initialize(error_hash = {}) ⇒ ParserError
constructor
A new instance of ParserError.
- #syntax? ⇒ Boolean
- #to_s ⇒ Object
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
43 44 45 |
# File 'lib/sparkql/errors.rb', line 43 def constraint=(value) @constraint = value end |
#expression ⇒ Object
Returns the value of attribute expression.
41 42 43 |
# File 'lib/sparkql/errors.rb', line 41 def expression @expression end |
#message ⇒ Object
Returns the value of attribute message.
41 42 43 |
# File 'lib/sparkql/errors.rb', line 41 def @message end |
#nested_errors ⇒ Object
Returns the value of attribute nested_errors.
41 42 43 |
# File 'lib/sparkql/errors.rb', line 41 def nested_errors @nested_errors end |
#recovered_as ⇒ Object
Returns the value of attribute recovered_as.
41 42 43 |
# File 'lib/sparkql/errors.rb', line 41 def recovered_as @recovered_as end |
#sparkql ⇒ Object
Returns the value of attribute sparkql.
41 42 43 |
# File 'lib/sparkql/errors.rb', line 41 def sparkql @sparkql end |
#status ⇒ Object
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
43 44 45 |
# File 'lib/sparkql/errors.rb', line 43 def syntax=(value) @syntax = value end |
#token ⇒ Object
Returns the value of attribute token.
41 42 43 |
# File 'lib/sparkql/errors.rb', line 41 def token @token end |
#token_index ⇒ Object
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
63 64 65 |
# File 'lib/sparkql/errors.rb', line 63 def constraint? @constraint end |
#syntax? ⇒ Boolean
59 60 61 |
# File 'lib/sparkql/errors.rb', line 59 def syntax? @syntax end |
#to_s ⇒ Object
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 |