Exception: PgVerify::Model::Validation::AssignmentToStateVariableError

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(variable, expression, varset) ⇒ AssignmentToStateVariableError

Returns a new instance of AssignmentToStateVariableError.



86
87
88
# File 'lib/pg-verify/model/validation/errors.rb', line 86

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

Instance Method Details

#formattedObject



89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/pg-verify/model/validation/errors.rb', line 89

def formatted()
    title = "Assignment to state variable"
    
    body = []
    body << @expression.source_location.to_s.c_sidenote
    body << @expression.source_location.render_code_block()
    body << ""
    body << "The expression '#{@expression.to_s.c_expression}' assigns a value to variable #{@variable.to_s.c_var}."
    body << "However this variable is a state variable and can not be written to."
    
    hint = "State variables are read only"
    
    return title, body.join("\n"), hint
end