gulp-combine-media-queries icon indicating copy to clipboard operation
gulp-combine-media-queries copied to clipboard

Error not catched in css-parse

Open tkjaergaard opened this issue 10 years ago • 5 comments

When css-parse encounters an error it throws a new Error object which is not caught in index,js:125

This causes the watch workflow in Gulp to crash due to an unhandled error and is also resulting the .on('error') event not to be triggered.

Please look at some options to catch the error and throw a PluginError instead?

tkjaergaard avatar Mar 04 '14 13:03 tkjaergaard

@tkjaergaard Hi.

I do not know well how to receive the error css-parse can throw.

https://github.com/reworkcss/css-parse#errors

I do think I think we can deal with such a situation to add code similar to the following, but do you intent not match the thing you are you said?

var cssJson = parseCss(source);

try {
  file.contents = new Buffer(cssJson);
} catch (err) {
  this.emit('error', new PluginError(PLUGIN_NAME, err));
}

konitter avatar Mar 11 '14 05:03 konitter

That could be a valid solution to overcome this issue?

tkjaergaard avatar Mar 19 '14 10:03 tkjaergaard

Since try if the problem can be solved, why not tell me the CSS code that has a problem css-parse such that an error?

konitter avatar Mar 19 '14 12:03 konitter

Sorry mate, but what you just wrote doesn't make any sense to me? :)

tkjaergaard avatar Mar 19 '14 12:03 tkjaergaard

Hi, i just encountered a similar issue. but the error message in the terminal give me the line where it crash. In fact the parser crash in my case, with a missing ';' at the end of the class declaration.this can be considered as correct in a css validation normaly.

.thumbnails li.thumbnail {
  display: block;
  padding: 0.3125em;
  margin-bottom: 1.2em;
  line-height: 23px;
  background-color: white;
  border: 1px solid silver;
  border-radius: 5px
}

mistergraphx avatar Dec 11 '14 15:12 mistergraphx