Exception: PgVerify::Model::Validation::UnknownTokenError

Inherits:
Core::Error
  • Object
show all
Defined in:
lib/pg-verify/model/validation/errors.rb

Instance Method Summary collapse

Methods inherited from Core::Error

#to_formatted

Constructor Details

#initialize(token, expression, varset) ⇒ UnknownTokenError

Returns a new instance of UnknownTokenError.



23
24
25
# File 'lib/pg-verify/model/validation/errors.rb', line 23

def initialize(token, expression, varset)
    @token, @expression, @varset = token, expression, varset
end

Instance Method Details

#formattedObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/pg-verify/model/validation/errors.rb', line 26

def formatted()
    title = "Unknown token"
    
    body = []
    body << @expression.source_location.to_s.c_sidenote  unless @expression.source_location.nil?
    body << @expression.source_location.render_code_block() unless @expression.source_location.nil?
    body << ""
    body << "The expression '#{@expression.to_s.c_expression}' uses token #{@token.to_s.c_string}."
    body << "This is neither a known variable, nor literal."
    body << "Known variables: #{@varset.names.map(&:to_s).map(&:c_var).join(", ")}"
    body << "Known literals: #{@varset.values.reject{ |v| v.is_a?(Numeric) }.map(&:to_s).map(&:c_literal).join(", ")}"
    
    return title, body.join("\n")
end