企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
错误,与提示有所不同,将会中断编译器的下一步进程。基本上,它们中断编译并像堆栈跟踪一样在输出流中显示相关信息,这对调试很有帮助。因此,如果程序无法继续执行就应该抛出错误。如有可能,尝试解决这个问题并以显示提醒的方式代替。 举个例子,假设你创建了一个 getter 函数来从特定 map 中获取值。如果想要获取的值并不在 map 中,就可能会抛出错误。 ~~~ /// Z-indexes map, gathering all Z layers of the application /// @access private /// @type Map /// @prop {String} key - Layer’s name /// @prop {Number} value - Z value mapped to the key $z-indexes: ( 'modal': 5000, 'dropdown': 4000, 'default': 1, 'below': -1, ); /// Get a z-index value from a layer name /// @access public /// @param {String} $layer - Layer's name /// @return {Number} /// @require $z-indexes @function z($layer) { @if not map-has-key($z-indexes, $layer) { @error 'There is no layer named `#{$layer}` in $z-indexes. ' + 'Layer should be one of #{map-keys($z-indexes)}.'; } @return map-get($z-indexes, $layer); } ~~~