Exception: PgVerify::Model::Validation::UnknownVariableError
- Inherits:
-
Core::Error
- Object
- StandardError
- Core::Error
- PgVerify::Model::Validation::UnknownVariableError
- Defined in:
- lib/pg-verify/model/validation/errors.rb
Instance Method Summary collapse
- #formatted ⇒ Object
-
#initialize(assigned_variable, assignment_expression, var_set) ⇒ UnknownVariableError
constructor
A new instance of UnknownVariableError.
Methods inherited from Core::Error
Constructor Details
#initialize(assigned_variable, assignment_expression, var_set) ⇒ UnknownVariableError
Returns a new instance of UnknownVariableError.
43 44 45 |
# File 'lib/pg-verify/model/validation/errors.rb', line 43 def initialize(assigned_variable, assignment_expression, var_set) @assigned_variable, @assignment_expression, @var_set = assigned_variable, assignment_expression, var_set end |
Instance Method Details
#formatted ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/pg-verify/model/validation/errors.rb', line 46 def formatted() title = "Unknown variable '#{@assigned_variable}'" body = [] body << @assignment_expression.source_location.to_s.c_sidenote body << @assignment_expression.source_location.render_code_block() body << "" body << "The expression '#{@assignment_expression.to_s.c_expression}' uses variable #{@assigned_variable.to_s.c_var}." body << "However there is no such variable in the context of this model." body << "Known variables: #{@var_set.names.map(&:to_s).map(&:c_var).join(', ')}." hint = "Declare variables before using them in expressions" return title, body.join("\n"), hint end |