test-fullautomation / python-jsonpreprocessor

A preprocessor for json files
Apache License 2.0
2 stars 2 forks source link

Error messages need to be aligned #277

Open HolQue opened 1 month ago

HolQue commented 1 month ago

All following codes have the same issue: By mistake a string is used as list index. But the error messages are different.

Code:

${testlist}['ABC'] : 4

Error message:

Error: 'Could not set variable '${testlist}['ABC']' with value '4'! Reason: list indices must be integers or slices, not str'!

Code:

"param" : ${testlist}['ABC']
"param" : "${testlist}['ABC']"

Error message:

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

Code:

"param" : ${testlist}['${intval}']
"param" : "${testlist}['${intval}']"

Error message:

Error: '${testlist} expects integer as index. Got string instead in ${testlist}['${intval}']'!

From where do these error message deviations come from? I would expect one certain function to do the type check. Therefore the same error message is expected in all cases above.

I would prefer the last error message version. This also would avoid the 'slices' issue of the first one (see also https://github.com/test-fullautomation/python-jsonpreprocessor/issues/205#issuecomment-2044578868).