Permalink
Browse files

show meaningful less errors intead of message "[Object object]"

  • Loading branch information...
1 parent 68b4ec2 commit 74ac6ab8f212514a194adab3a5919981e07d20e7 @vicapow committed Mar 18, 2013
Showing with 27 additions and 21 deletions.
  1. +27 −21 lib/assets.js
View
@@ -83,27 +83,33 @@ var CssAsset = rack.Asset.extend({
}, function(error) {
if(error) self.emit('error', error);
var parser = new less.Parser();
- parser.parse(self.lessContents, function(error, tree) {
- if (error) return self.emit('error');
- var lessAsset = new rack.Asset({
- url: '/assets/styles/style.less.css',
- mimetype: 'text/css',
- contents: tree.toCSS()
- });
- lessAsset.isDev = true;
- self.assets.push(lessAsset);
- lessAsset.on('complete', function() {
- self.contents = '';
- if (isProduction) {
- _.each(self.assets, function(asset) {
- self.contents += asset.contents += '\n';
- });
- self.contents = cleancss.process(self.contents);
- }
- self.isDev = false;
- self.emit('created');
- });
- });
+ try{
+ parser.parse(self.lessContents, function(error, tree) {
+ if (error) return self.emit('error');
+ var lessAsset = new rack.Asset({
+ url: '/assets/styles/style.less.css',
+ mimetype: 'text/css',
+ contents: tree.toCSS()
+ });
+ lessAsset.isDev = true;
+ self.assets.push(lessAsset);
+ lessAsset.on('complete', function() {
+ self.contents = '';
+ if (isProduction) {
+ _.each(self.assets, function(asset) {
+ self.contents += asset.contents += '\n';
+ });
+ self.contents = cleancss.process(self.contents);
+ }
+ self.isDev = false;
+ self.emit('created');
+ });
+ });
+ }catch(e){
+ // less could still throw an error that isn't of type `Error`
+ sails.log.error('Less compilation error');
+ less.writeError(e);
+ }
});
}
});

0 comments on commit 74ac6ab

Please sign in to comment.