Exception: PgVerify::Model::Validation::ForeignVariableAssignmentError

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, component) ⇒ ForeignVariableAssignmentError

Returns a new instance of ForeignVariableAssignmentError.



64
65
66
67
# File 'lib/pg-verify/model/validation/errors.rb', line 64

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

Instance Method Details

#formattedObject



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/pg-verify/model/validation/errors.rb', line 68

def formatted()
    title = "Foreign variable assignment"
    
    body = []
    body << @expression.source_location.to_s.c_sidenote
    body << @expression.source_location.render_code_block()
    body << ""
    body << "Component #{@component.name.to_s.c_cmp} assigns a value to variable #{@variable.to_s.c_var},"
    body << "using this expression '#{@expression.to_s.c_expression}'."
    body << "However #{@variable.to_s.c_var} is owned by component #{@varset[@variable].owner_name.to_s.c_cmp}"
    
    hint = "A variable can only be written to by the component which declared it"
    
    return title, body.join("\n"), hint
end