Re: Catching InvalidReferenceException
David Haraburda <[email protected]> Mon, 21 Jul 2014 11:01:02 -0500
| Newsgroups | gmane.comp.web.freemarker.devel |
|---|---|
| Message-ID | <CAOKMbGeRDQyLyOc9tqDs0DuO7dpZgwxJgc5CQ5LJpbuQsNBCjw@mail.gmail.com> |
Thanks Daniel. I don't see a 2.3.21 branch on github but we would probably wait for an official release anyway. What you describe sounds like it will work perfect for our use case. Thanks again, David On Sun, Jul 20, 2014 at 11:54 AM, Daniel Dekany <[email protected]> wrote: > Wednesday, July 16, 2014, 9:56:04 PM, David Haraburda wrote: > > > I noticed that when InvalidReferenceException is thrown, it would > > potentially be useful if the exception exposed the string of the > > invalid expression directly as an attribute. That way code that > > catches the exception can say ex.getExpression() and use this to > > generate it's own error message (i.e. internationalized) or do further > processing. > > > > Would a simple patch that allows this be accepted if I submitted > > one to the project? Or is there a better way to directly get at the > offending expression? > > In 2.3.21, if you check that out from GitHub (it's not yet released), > InvalidReferenceException inherits such facility from > TemplateException: getBlamedExpressionString(). (As the > freemarker.core.Expression API is not published, you can't get the > Expression yet, but maybe it helps that said method returns the > canonical form so you don't have to do tricky normalizations to > extract some info.) You can also get the location of the offending > expression. > > > Thanks, > > > > David > > -- > Thanks, > Daniel Dekany > > ------------------------------------------------------------------------------ Want fast and easy access to all the code in your enterprise? Index and search up to 200,000 lines of code with a free copy of Black Duck Code Sight - the same software that powers the world's largest code search on Ohloh, the Black Duck Open Hub! Try it now. http://p.sf.net/sfu/bds _______________________________________________ FreeMarker-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/freemarker-devel