[stringtemplate-interest] [ST4] How to notice errors when a file was not imported?
Terence Parr
parrt at cs.usfca.edu
Sat Feb 5 12:07:00 PST 2011
Good suggestion.
fixed.
Ter
On Jan 31, 2011, at 3:17 PM, Udo Borkowski wrote:
> 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.
>
>
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org/mailman/listinfo/stringtemplate-interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20110205/85ad6471/attachment.html
More information about the stringtemplate-interest
mailing list