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.
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/sparkql/errors.rb', line 43 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 self.constraint = error_hash[:constraint] == true end |
Instance Attribute Details
#constraint=(value) ⇒ Object (writeonly)
Sets the attribute constraint
41 42 43 |
# File 'lib/sparkql/errors.rb', line 41 def constraint=(value) @constraint = value end |
#expression ⇒ Object
Returns the value of attribute expression.
39 40 41 |
# File 'lib/sparkql/errors.rb', line 39 def expression @expression end |
#message ⇒ Object
Returns the value of attribute message.
39 40 41 |
# File 'lib/sparkql/errors.rb', line 39 def @message end |
#nested_errors ⇒ Object
Returns the value of attribute nested_errors.
39 40 41 |
# File 'lib/sparkql/errors.rb', line 39 def nested_errors @nested_errors end |
#recovered_as ⇒ Object
Returns the value of attribute recovered_as.
39 40 41 |
# File 'lib/sparkql/errors.rb', line 39 def recovered_as @recovered_as end |
#sparkql ⇒ Object
Returns the value of attribute sparkql.
39 40 41 |
# File 'lib/sparkql/errors.rb', line 39 def sparkql @sparkql end |
#status ⇒ Object
Returns the value of attribute status.
39 40 41 |
# File 'lib/sparkql/errors.rb', line 39 def status @status end |
#syntax=(value) ⇒ Object (writeonly)
Sets the attribute syntax
41 42 43 |
# File 'lib/sparkql/errors.rb', line 41 def syntax=(value) @syntax = value end |
#token ⇒ Object
Returns the value of attribute token.
39 40 41 |
# File 'lib/sparkql/errors.rb', line 39 def token @token end |
#token_index ⇒ Object
Returns the value of attribute token_index.
39 40 41 |
# File 'lib/sparkql/errors.rb', line 39 def token_index @token_index end |
Instance Method Details
#constraint? ⇒ Boolean
61 62 63 |
# File 'lib/sparkql/errors.rb', line 61 def constraint? @constraint end |
#syntax? ⇒ Boolean
57 58 59 |
# File 'lib/sparkql/errors.rb', line 57 def syntax? @syntax end |
#to_s ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/sparkql/errors.rb', line 65 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 "Recovered as #{@recovered_as}: " else "" end str += "<#{@token}> in " unless @token.nil? str += "<#{@expression}>: #{@message}." str end |