zap
zap copied to clipboard
Make XML errors easier to debug during codegen
We had a type error recently in two separate reasons: uint16 used instead of int16u and once a type being "" (not sure why ... maybe an erase that was never updated).
The code generator failed with very hard to debug errors like:
TypeError: Cannot read properties of undefined (reading 'startsWith')
at Object.atomicType (/snapshot/zap/dist/src-electron/generator/overridable.js:63:14)
at Object.atomicType (/snapshot/zap/dist/src-electron/generator/template-engine.js:175:31)
at /snapshot/zap/dist/src-electron/util/zcl-util.js:545:47
at async Promise.all (index 0)
Instead we should have some context on various things, in this case for example atomicType should at least tell me what type it was trying to process, so I could have seen uint16 being at fault.
Ideally though, we should also have XML context inside types. I would have liked the trace to tell me "in foo.xml, type defined at line 123 failed to be processed" and then human review would have been much easier. As it stands we had to bisect all types one by one in XML which is very slow.
@andy31415 we have XML type warnings like this
also if you click extensions you can see
Checked offline, the existing warnings did not catch the errors in the XML I had (neither empty type nor using uint16 instead of int16u)