[英]How to throw custom error when node-sass compile sass code?
I choose node-sass to compile my sass code, but what things can I do when the code is compiling?我选择node-sass来编译我的sass代码,但是在编译代码的时候可以做什么呢?
In other words, I want make my own rules and throw custom errors in certain condition when compiling.换句话说,我想制定自己的规则并在编译时在某些条件下抛出自定义错误。
If you have a look for node-sass (according to 3.xx)
documentation (on the readme) - it explains how to add your own error messaging via the error
object when you render.如果您查看 node-sass
(according to 3.xx)
文档(在自述文件中) - 它解释了如何在渲染时通过error
对象添加您自己的错误消息。
from documentation
来自文档
var sass = require('node-sass');
sass.render({
file: scss_filename,
[, options..]
}, function(err, result) { /*...*/ });
custom error message
自定义错误信息
var sass = require('node-sass');
sass.render({
file: scss_filename,
[, options..]
}, function(err, result) {
if (err) throw new Error(err)
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.