[stringtemplate-interest] [ST4] How to notice errors when a file was not imported?

Udo Borkowski ub at abego-software.de
Mon Jan 31 15:36:56 PST 2011


What about making the constant STGroup.DEFAULT_ERR_MGR a variable/property? This way a different DefaultErrorManager could be defined. The default would be the current "new ErrorManager()". 

Or define a new STGroup property initialErrorManager that is initialized with the DEFAULT_ERR_MGR. initialErrorManager is then used instead of DEFAULT_ERR_MGR. 

Udo


On 01.02.2011, at 00:17, 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/20110201/b1099b54/attachment.html 


More information about the stringtemplate-interest mailing list