zap icon indicating copy to clipboard operation
zap copied to clipboard

Make XML errors easier to debug during codegen

Open andy31415 opened this issue 2 years ago • 3 comments

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 avatar Nov 08 '23 15:11 andy31415

@andy31415 we have XML type warnings like this Screenshot 2023-11-09 at 12 49 01 PM

paulr34 avatar Nov 09 '23 17:11 paulr34

also if you click extensions you can see Screenshot 2023-11-09 at 12 50 56 PM

paulr34 avatar Nov 09 '23 17:11 paulr34

Checked offline, the existing warnings did not catch the errors in the XML I had (neither empty type nor using uint16 instead of int16u)

andy31415 avatar Nov 09 '23 19:11 andy31415