google-code-export / wro4j

Automatically exported from code.google.com/p/wro4j
1 stars 1 forks source link

Improve error messages of CssLintProcessor [patch] #910

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
This patch improves the error messages produces by the CssLintProcessor.

Original issue reported on code.google.com by jens.ask...@gmail.com on 27 Nov 2014 at 9:41

GoogleCodeExporter commented 9 years ago
diff --git 
a/wro4j-extensions/src/main/java/ro/isdc/wro/extensions/processor/css/CssLintPro
cessor.java 
b/wro4j-extensions/src/main/java/ro/isdc/wro/extensions/processor/css/CssLintPro
cessor.java
index ac78a47..8756919 100644
--- 
a/wro4j-extensions/src/main/java/ro/isdc/wro/extensions/processor/css/CssLintPro
cessor.java
+++ 
b/wro4j-extensions/src/main/java/ro/isdc/wro/extensions/processor/css/CssLintPro
cessor.java
@@ -16,6 +16,7 @@
 import ro.isdc.wro.WroRuntimeException;
 import ro.isdc.wro.extensions.processor.support.ObjectPoolHelper;
 import ro.isdc.wro.extensions.processor.support.csslint.CssLint;
+import ro.isdc.wro.extensions.processor.support.csslint.CssLintError;
 import ro.isdc.wro.extensions.processor.support.csslint.CssLintException;
 import ro.isdc.wro.model.resource.Resource;
 import ro.isdc.wro.model.resource.ResourceType;
@@ -75,7 +76,6 @@
       cssLint.setOptions(options).validate(content);
     } catch (final CssLintException e) {
       try {
-        LOG.error("The following resource: " + resource + " has " + 
e.getErrors().size() + " errors.", e);
         onCssLintException(e, resource);
       } catch (final Exception ex) {
         WroUtil.wrapWithWroRuntimeException(e);
@@ -126,6 +126,10 @@
    * @param resource the processed resource which caused the exception.
    */
   protected void onCssLintException(final CssLintException e, final Resource resource) throws Exception {
-    LOG.error("The following resource: " + resource + " has " + 
e.getErrors().size() + " errors.", e);
+    String uri = resource == null ? StringUtils.EMPTY : resource.getUri();
+    for (CssLintError x : e.getErrors())
+    {
+      LOG.error(uri + " line " + x.getLine() + " column " + x.getCol() + ": " 
+ x.getType() + " " + x.getMessage() + " " + e.getEvidence());
+    }
   }
 }

Original comment by jens.ask...@gmail.com on 27 Nov 2014 at 9:43

GoogleCodeExporter commented 9 years ago
Thanks!

Original comment by alex.obj...@gmail.com on 27 Nov 2014 at 9:48