improvement of error messages

84 views
Skip to first unread message

stephanos

unread,
Apr 23, 2011, 5:18:27 AM4/23/11
to wro4j
At first let me say I'm very fond of the new error message reporting
in the maven builds.
But I think there is still a little room for improvement.


1) example error from CoffeeScript processor:

# [INFO] processing group: framework.js
# 29474 ERROR RhinoScriptBuilder - JavaScriptException occured:
SyntaxError: Reserved word "var" on line 2 (coffee-script-1.0.1.js#8)
# 29474 WARN CoffeScriptProcessor - Exception while applying
CoffeScriptProcessor processor on the resource, no processing
applied...
# ro.isdc.wro.WroRuntimeException: Could not execute the script
because: {"message":"Reserved word \"var\" on line 2"}
# at
ro.isdc.wro.extensions.processor.algorithm.coffeescript.CoffeeScript.compile(CoffeeScript.java:
68)
# at
ro.isdc.wro.extensions.processor.js.CoffeScriptProcessor.process(CoffeScriptProcessor.java:
47)
# at
ro.isdc.wro.extensions.processor.js.CoffeScriptProcessor.process(CoffeScriptProcessor.java:
81)
# ...
# [INFO] file size: framework.js -> 23639 bytes

In this stacktrace I can't seem to find any information about
the .coffee file that causes this error. It would be very helpful
though.


2) example from LessCSS processor:

# 6001 ERROR RhinoScriptBuilder - JavaScriptException occured:
[object Object] (less-1.0.41.min.js#23)
# 6003 WARN LessCssProcessor - Exception while applying lessCss
processor on the resource, no processing applied...
# ro.isdc.wro.WroRuntimeException: Could not execute the script
because:
#
{"type":"org.mozilla.javascript.Undefined@77b8378f","message":".width
is undefined","filename":null,"index":258.0,"line":
9.0,"callLine":"org.mozilla.javascript.Undefined@77b8378f","callExtract":"org.mozilla.javascript.Undefined@77b8378f","stack":"org.mozilla.javascript.Undefined@77b8378f","column":
4.0,"extract":["#profileBoard {"," .width(750px);",""]}
# at
ro.isdc.wro.extensions.processor.algorithm.less.LessCss.less(LessCss.java:
69)
# at
ro.isdc.wro.extensions.processor.css.LessCssProcessor.process(LessCssProcessor.java:
117)
# at
ro.isdc.wro.extensions.processor.css.LessCssProcessor.process(LessCssProcessor.java:
152)
# ...

This stacktrace is also missing information about which file contains
this error - the filename parameter is just 'null'.


It would be great to see the suggested improvements, making wro4j even
better :)

Cheers,
Stephan

stephanos

unread,
Apr 23, 2011, 7:15:56 AM4/23/11
to wro4j
Oh, and one more thing:
It appears as though the CoffeeScript processor also tries to
compile .js files when I mix .js/.coffee resources in the same group.
Maybe it could check for the file ending and skip non-coffee files?

I solved it like this (Scala):

class MyCoffeScriptProcessor extends CoffeScriptProcessor {

override def process(resource: Resource, reader: Reader,
writer: Writer) {
if (resource.getUri endsWith ".coffee")
super.process(resource, reader, writer)
else {
try {
writer.write(IOUtils.toString(reader))
}
finally {
reader.close()
writer.close()
> 9.0,"callLine":"org.mozilla.javascript.Undefined@77b8378f","callExtract":"o rg.mozilla.javascript.Undefined@77b8378f","stack":"org.mozilla.javascript.U ndefined@77b8378f","column":

Alex Objelean

unread,
Apr 24, 2011, 7:09:50 AM4/24/11
to wr...@googlegroups.com
Hi Stephan,

this is an expected behavior. Preprocessors are applied on all resources before they are merged and post processors are applied after the resource content is merged. The only aspect worth mention is that some of the processors are designed to work on JS resources, some on CSS resources and some on both resources. This can be controlled by the SupportedResource annotation.

Actually it is not a problem if a plain javascript is processed by coffee script processor, because the result will not be changed if any errors occurs during processing. That is why it is important o use coffee script as a pre processor when you mix js code with coffee script code. 

Your approach is still valid if you want a custom processing logic. The flexibility wro4j provides, allows you easily implement a solution like this. 

Regards, 
Alex 

--
You received this message because you are subscribed to the Google Groups "wro4j" group.
To post to this group, send email to wr...@googlegroups.com.
To unsubscribe from this group, send email to wro4j+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/wro4j?hl=en.


Alex Objelean

unread,
Apr 24, 2011, 7:13:18 AM4/24/11
to wr...@googlegroups.com
Thanks for suggestion.
I'll address this problem in the next release.

Cheers,
Alex

Reply all
Reply to author
Forward
0 new messages