在Sass中引发自定义错误/警告

在Sass中引发自定义错误/警告,sass,Sass,我正在创建一个字体模块,其中包含我所有的webfonts和一些Sass混合体,用于写出@font-face声明。主混合器将类似于includeFont(名称、重量、样式) 我将在一些Sass变量中保存一个记录,记录哪些字体的权重和样式实际上是可用的,通过对此的巧妙处理,我认为我可以编写mixin,这样我就可以检测我是否尝试请求一种不存在的字体 但当我检测到这种情况时,如何抛出错误?截至,有一条指令可用于导致致命错误: $stuff:fubar; @如果($stuff==fubar){ @错误“东

我正在创建一个字体模块,其中包含我所有的webfonts和一些Sass混合体,用于写出
@font-face
声明。主混合器将类似于
includeFont(名称、重量、样式)

我将在一些Sass变量中保存一个记录,记录哪些字体的权重和样式实际上是可用的,通过对此的巧妙处理,我认为我可以编写mixin,这样我就可以检测我是否尝试请求一种不存在的字体

但当我检测到这种情况时,如何抛出错误?

截至,有一条指令可用于导致致命错误:

$stuff:fubar;
@如果($stuff==fubar){
@错误“东西是fubar”;
}
如果您尝试在shell中编译它,您将看到以下内容:

$ sass test.scss
Error: stuff is fubar
        on line 3 of test.scss
  Use --trace for backtrace.
编译时:

$ sass test2.scss
test2.scss:1 DEBUG: stuff is happening
WARNING: stuff is happening that probably shouldn't be happening
         on line 2 of test2.scss

/*
    Note that these directives do not terminate execution, and this block
    will therefore still be output.
*/
* {
  color: pink; }
$sass test2.scss
test2.scss:1调试:事情正在发生
警告:正在发生的事情可能不应该发生
在test2.scss的第2行
/*
请注意,这些指令不会终止执行,并且此块
因此仍将是输出。
*/
* {
颜色:粉红色;}
$ sass test2.scss
test2.scss:1 DEBUG: stuff is happening
WARNING: stuff is happening that probably shouldn't be happening
         on line 2 of test2.scss

/*
    Note that these directives do not terminate execution, and this block
    will therefore still be output.
*/
* {
  color: pink; }