You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TOSCA parsing and validation error messages should include source filename and line number. We have the original parsed yaml nodes elements available we just need to preserve that info all the way down to where the exception is raised.
A sketch:
Make yamlloader.py saves the file name in addition to the base_dir.
Update make_map_with_base() in merge.py to preserve the CommentedMap's lc attribute.
From https://yaml.readthedocs.io/en/latest/detail.html: "collection objects (when read in via RoundTripParser) have an lc property that contains line and column info lc.line and lc.col. Individual positions for mappings and sequences can also be retrieved (lc.key('a'), lc.value('a') resp. lc.item(3))"
lc = getattr(doc, "lc", None)
...
if lc is not None:
map.lc.line = lc.line
map.lc.col = lc.col
Add a near class attribute to ExceptionCollector and update the ctors for the base TOSCA element classes to set their tpl instance to that class, e.g. EntityTemplate could add:
ExceptionCollector.near = (self, self.entity_tpl)
Add a line like self.near = ExceptionCollector.near to TOSCAException ctor
Now we have enough info to augment the error message with a sentence like "error in near line n in file f
The text was updated successfully, but these errors were encountered:
I didn't see lc on the CommentMap objects, not sure why... So as a hack I'm just assigning help for messages to ExceptionCollector .near in a few place in the parsing process, just search for "near" in tosca-parser.
TOSCA parsing and validation error messages should include source filename and line number. We have the original parsed yaml nodes elements available we just need to preserve that info all the way down to where the exception is raised.
A sketch:
Make yamlloader.py saves the file name in addition to the base_dir.
Update
make_map_with_base()
inmerge.py
to preserve the CommentedMap'slc
attribute.From https://yaml.readthedocs.io/en/latest/detail.html: "collection objects (when read in via RoundTripParser) have an lc property that contains line and column info lc.line and lc.col. Individual positions for mappings and sequences can also be retrieved (lc.key('a'), lc.value('a') resp. lc.item(3))"
lc = getattr(doc, "lc", None)
...
if lc is not None:
map.lc.line = lc.line
map.lc.col = lc.col
Add a
near
class attribute to ExceptionCollector and update the ctors for the base TOSCA element classes to set theirtpl
instance to that class, e.g.EntityTemplate
could add:Add a line like
self.near = ExceptionCollector.near
toTOSCAException
ctorNow we have enough info to augment the error message with a sentence like "error in near line n in file f
The text was updated successfully, but these errors were encountered: