Permalink
Browse files

new file

  • Loading branch information...
1 parent 2535145 commit 7c0d5540fc9a6762e77552b5b8c2cb51b800e33c @rc1 committed Mar 28, 2012
Showing with 26 additions and 0 deletions.
  1. +26 −0 connect-less-errors.js
View
@@ -0,0 +1,26 @@
+var path = require('path');
+
+module.exports = function (err, req, res, next) {
+ if (path.extname(req.url) === '.css') {
+
+ var details = "/* Less CSS: " + err.name + "\n" +
+ " * \n"+
+ " * in : " + path.basename(req.url, "css") + ".less \n" +
+ " * line : " + err.line + "\n" +
+ " * column : " + err.column + "\n" +
+ " * errors :";
+
+ for (var index in err.extract) {
+ details += " " + err.extract[index] + "\n * ";
+ }
+
+ details += "\n" +
+ " * Output : " + JSON.stringify(err) + "\n" +
+ "*/";
+
+ res.writeHead(200, {'Content-Type': 'text/css'});
+ res.end(details);
+ } else {
+ next(err);
+ }
+};

0 comments on commit 7c0d554

Please sign in to comment.