Skip to content

Error handling improvements (1) #207

@HolQue

Description

@HolQue

I have some doubts about the outcome and the error messages caused by the following code examples:

(1)
Negative integer applied to a string:

"param1" : "value",
"param2" : ${param1}[-1]

Result:

Error: 'Invalid nested parameter format: ${param1}[-1] - The double quotes are missing!!!'!

Therefore with double quotes:

"param1" : "value",
"param2" : "${param1}[-1]"

Result:

{'param1': 'value', 'param2': 'e[-1]'}

(2)
The same with a list:

"testlist" : [1,2,3],
"value"    : ${testlist}[-1]

Result:

Error: 'Invalid nested parameter format: ${testlist}[-1] - The double quotes are missing!!!'!

Therefore with double quotes:

"testlist" : [1,2,3],
"value"    : "${testlist}[-1]"

Result:

{'testlist': [1, 2, 3], 'value': '3[-1]'}

(3)
Same with pair of empty square brackets:

"param1" : "value",
"param2" : ${param1}[]

Error: 'Invalid nested parameter format: ${param1}[] - The double quotes are missing!!!'!

"param1" : "value",
"param2" : "${param1}[]"

Error: 'The variable '${param1}[]' is not available!'!

"testlist" : [1,2,3],
"value"    : ${testlist}[]

Error: 'Invalid nested parameter format: ${testlist}[] - The double quotes are missing!!!'!

"testlist" : [1,2,3],
"value"    : "${testlist}[]"

Error: 'The variable '${testlist}[]' is not available!'!

In all cases above the square brackets are part of a dollar operator expression containing an existing parameter. Therefore the brackets have a syntactical meaning. Therefore strict syntax rules can be applied to them:

  1. Negative integers are not allowed inside square brackets (would be a slicing issue). At least invalid mixed results like '3[-1]' must not occur.
  2. A pair of square brackets must not be empty

I would assume now that it is possible to provide an error message like:

Expression '${testlist}[]' cannot be evaluated. Reason: Empty pair of square brackets detected.

This would be more helpful than simply telling that a variable does not exist.

Metadata

Metadata

Assignees

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions