[stringtemplate-interest] [ST4] How to notice errors when a file was not imported?
Udo Borkowski
ub at abego-software.de
Mon Jan 31 15:17:32 PST 2011
Hi,
I created an own ErrorListener that collects all error message in a list for later retrieval. I set the listener for every group immediately after it is created.
I now noticed that I don't get the errors when I am importing a group and the referenced group file does not exist. The error is written to the console, using the STGroup.DEFAULT_ERR_MGR.
This is because the error occurs inside the constructor STGroupFile(String fileName, char delimiterStartChar, char delimiterStopChar) and it writes to the group's errMgr. This errMgr is always the STGroup.DEFAULT_ERR_MGR because there is no chance to change the errMgr as the group is just instantiated.
Any idea how to fix this?
What about throwing an exception when an error occurs in the STGroupFile constructor (instead of using the errMgr) and let the caller handle the rest? E.g. in the STGroupFile constructor replace
errMgr.internalError(null, "can't load group file "+fileName, e);
with
throw new STException("can't load group file "+fileName, e);
?
Udo
P.S.: the same problem exists for STGroupDir, I guess.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20110201/9ef394dc/attachment.html
More information about the stringtemplate-interest
mailing list