Problem with the function's error stacktrace and debugging

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with the function's error stacktrace and debugging

Albert Kam
I have just faced this situation where the error message is not suffucient to determine stacktrace of ftl-s that lead to the error.

So, i have an ftl file :

<@layout.main>
   my page contents here,
   calling another macro here : ${url.myUrlToAnotherPage(paramsHere)}
</@layout.main>

Now, in the url.ftl file, i have the function of myUrlToAnotherPage, which calls other functions that exist in the url.ftl.

But the error message only display it like this :

Error on line 23, column 48 in lib/url.ftl
Expecting a string, date or number here, Expression finalValue is instead a freemarker.template.SimpleSequence
The problematic instruction:
----------
==> return [on line 23, column 17 in lib/url.ftl] [on line 23, column 17 in lib/url.ftl]
 in user-directive layout.layout [on line 11, column 1 in post/ad/no0035.ftl]
----------
With this error message, i know that the rror is on line 23, another function called blah for example. But i dont know who calls blah, it's not in the stack trace.
After some dirty removing parts of the page to get the culprit, i found out that :
- wrap my page as a nested value for another macro (on line 11, displayed on the error stacktrace)
- my page calls url.myUrlToAnotherPage function
- url.myUrlToAnotherPage calls blahblah function
- blahblah calls blah function
- blah function errors (on line 23, displayed on the error stacktrace)

The second thing i want to ask that is related with this is :
How do i debug like the simple System.out.println in freemarker functions ?
Do i have to bind and call the java functions or something cool exists already in freemarker to achieve this ?

Thank you !
--
Do not pursue the past. Do not lose yourself in the future.
The past no longer is. The future has not yet come.
Looking deeply at life as it is in the very here and now,
the practitioner dwells in stability and freedom.
(Thich Nhat Hanh)

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and
their applications. This 200-page book is written by three acclaimed
leaders in the field. The early access version is available now.
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
Reply | Threaded
Open this post in threaded view
|

Re: Problem with the function's error stacktrace and debugging

Daniel Dekany
Wednesday, May 8, 2013, 1:02:19 PM, Albert Kam wrote:

> I have just faced this situation where the error message is not
> suffucient to determine stacktrace of ftl-s that lead to the error.
>
> So, i have an ftl file :
>
> <@layout.main>
>    my page contents here,
>    calling another macro here : ${url.myUrlToAnotherPage(paramsHere)}
> </@layout.main>
>
> Now, in the url.ftl file, i have the function of
> myUrlToAnotherPage, which calls other functions that exist in the url.ftl.
>
> But the error message only display it like this :
>
> Error on line 23, column 48 in lib/url.ftl
> Expecting a string, date or number here, Expression finalValue is
> instead a freemarker.template.SimpleSequence
> The problematic instruction:
> ----------
==>> return [on line 23, column 17 in lib/url.ftl] [on line 23, column 17 in lib/url.ftl]

>  in user-directive layout.layout [on line 11, column 1 in post/ad/no0035.ftl]
> ----------
> With this error message, i know that the rror is on line 23,
> another function called blah for example. But i dont know who calls
> blah, it's not in the stack trace.
> After some dirty removing parts of the page to get the culprit, i found out that :
> - wrap my page as a nested value for another macro (on line 11,
> displayed on the error stacktrace)
> - my page calls url.myUrlToAnotherPage function
> - url.myUrlToAnotherPage calls blahblah function
> - blahblah calls blah function
> - blah function errors (on line 23, displayed on the error stacktrace)

Looks like a bug or quality problem in the error reporting. I will try
to look into it in the future.

> The second thing i want to ask that is related with this is :
> How do i debug like the simple System.out.println in freemarker functions ?
> Do i have to bind and call the java functions or something cool
> exists already in freemarker to achieve this ?

Unfortunately not. Something like #log_[trace|debug|info|warn|error]
should be added, but it wasn't yet done. So for now you have to
implement your own directive or call a method for this. (You may want
to use the logging API of FreeMarker.)

> Thank you !

--
Thanks,
 Daniel Dekany


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and
their applications. This 200-page book is written by three acclaimed
leaders in the field. The early access version is available now.
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
Reply | Threaded
Open this post in threaded view
|

Re: Problem with the function's error stacktrace and debugging

Albert Kam
Hello again Mr Daniel. Thank you for your infos.

I have just made a simple scenario in hope to make your job easier !

Here's the source code : http://tny.cz/6e692350
And here's the ftl : http://tny.cz/6f502578
And here's the whole error in the stdout : http://tny.cz/5260ff75



On Thu, May 9, 2013 at 6:58 AM, Daniel Dekany <[hidden email]> wrote:
Wednesday, May 8, 2013, 1:02:19 PM, Albert Kam wrote:

> I have just faced this situation where the error message is not
> suffucient to determine stacktrace of ftl-s that lead to the error.
>
> So, i have an ftl file :
>
> <@layout.main>
>    my page contents here,
>    calling another macro here : ${url.myUrlToAnotherPage(paramsHere)}
> </@layout.main>
>
> Now, in the url.ftl file, i have the function of
> myUrlToAnotherPage, which calls other functions that exist in the url.ftl.
>
> But the error message only display it like this :
>
> Error on line 23, column 48 in lib/url.ftl
> Expecting a string, date or number here, Expression finalValue is
> instead a freemarker.template.SimpleSequence
> The problematic instruction:
> ----------
==>> return [on line 23, column 17 in lib/url.ftl] [on line 23, column 17 in lib/url.ftl]
>  in user-directive layout.layout [on line 11, column 1 in post/ad/no0035.ftl]
> ----------
> With this error message, i know that the rror is on line 23,
> another function called blah for example. But i dont know who calls
> blah, it's not in the stack trace.
> After some dirty removing parts of the page to get the culprit, i found out that :
> - wrap my page as a nested value for another macro (on line 11,
> displayed on the error stacktrace)
> - my page calls url.myUrlToAnotherPage function
> - url.myUrlToAnotherPage calls blahblah function
> - blahblah calls blah function
> - blah function errors (on line 23, displayed on the error stacktrace)

Looks like a bug or quality problem in the error reporting. I will try
to look into it in the future.

> The second thing i want to ask that is related with this is :
> How do i debug like the simple System.out.println in freemarker functions ?
> Do i have to bind and call the java functions or something cool
> exists already in freemarker to achieve this ?

Unfortunately not. Something like #log_[trace|debug|info|warn|error]
should be added, but it wasn't yet done. So for now you have to
implement your own directive or call a method for this. (You may want
to use the logging API of FreeMarker.)

> Thank you !

--
Thanks,
 Daniel Dekany


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and
their applications. This 200-page book is written by three acclaimed
leaders in the field. The early access version is available now.
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user



--
Do not pursue the past. Do not lose yourself in the future.
The past no longer is. The future has not yet come.
Looking deeply at life as it is in the very here and now,
the practitioner dwells in stability and freedom.
(Thich Nhat Hanh)

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and
their applications. This 200-page book is written by three acclaimed
leaders in the field. The early access version is available now.
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
Reply | Threaded
Open this post in threaded view
|

Re: Problem with the function's error stacktrace and debugging

Daniel Dekany
Thanks, I have attached them to my TODO.

--
Thanks,
 Daniel Dekany


Thursday, May 9, 2013, 4:12:49 PM, Albert Kam wrote:

> Hello again Mr Daniel. Thank you for your infos.
>
> I have just made a simple scenario in hope to make your job easier !
>
> Here's the source code : http://tny.cz/6e692350
> And here's the ftl : http://tny.cz/6f502578
> And here's the whole error in the stdout : http://tny.cz/5260ff75
>
>
>
> On Thu, May 9, 2013 at 6:58 AM, Daniel Dekany <[hidden email]> wrote:
> Wednesday, May 8, 2013, 1:02:19 PM, Albert Kam wrote:
>
>> I have just faced this situation where the error message is not
>> suffucient to determine stacktrace of ftl-s that lead to the error.
>>
>> So, i have an ftl file :
>>
>> <@layout.main>
>>    my page contents here,
>>    calling another macro here : ${url.myUrlToAnotherPage(paramsHere)}
>> </@layout.main>
>>
>> Now, in the url.ftl file, i have the function of
>> myUrlToAnotherPage, which calls other functions that exist in the url.ftl.
>>
>> But the error message only display it like this :
>>
>> Error on line 23, column 48 in lib/url.ftl
>> Expecting a string, date or number here, Expression finalValue is
>> instead a freemarker.template.SimpleSequence
>> The problematic instruction:
>> ----------
==>>> return [on line 23, column 17 in lib/url.ftl] [on line 23, column 17 in lib/url.ftl]

>>  in user-directive layout.layout [on line 11, column 1 in post/ad/no0035.ftl]
>> ----------
>> With this error message, i know that the rror is on line 23,
>> another function called blah for example. But i dont know who calls
>> blah, it's not in the stack trace.
>> After some dirty removing parts of the page to get the culprit, i found out that :
>> - wrap my page as a nested value for another macro (on line 11,
>> displayed on the error stacktrace)
>> - my page calls url.myUrlToAnotherPage function
>> - url.myUrlToAnotherPage calls blahblah function
>> - blahblah calls blah function
>> - blah function errors (on line 23, displayed on the error stacktrace)
>
> Looks like a bug or quality problem in the error reporting. I will try
> to look into it in the future.
>
>> The second thing i want to ask that is related with this is :
>> How do i debug like the simple System.out.println in freemarker functions ?
>> Do i have to bind and call the java functions or something cool
>> exists already in freemarker to achieve this ?
>
> Unfortunately not. Something like #log_[trace|debug|info|warn|error]
> should be added, but it wasn't yet done. So for now you have to
> implement your own directive or call a method for this. (You may want
> to use the logging API of FreeMarker.)
>
>> Thank you !
>
> --
> Thanks,
>  Daniel Dekany


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and
their applications. This 200-page book is written by three acclaimed
leaders in the field. The early access version is available now.
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
Reply | Threaded
Open this post in threaded view
|

Re: Problem with the function's error stacktrace and debugging

Daniel Dekany
This is now fixed on https://github.com/freemarker/freemarker/
(2.3-gae), so this will be part of the next release.

Friday, May 10, 2013, 11:51:19 PM, Daniel Dekany wrote:

> Thanks, I have attached them to my TODO.

--
Thanks,
 Daniel Dekany


------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j
_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user