2013-11-21 12 views
11

में चेतावनी मैं एक फ़ॉन्ट मॉड्यूल जो मेरे सारे वेबफ़ॉन्ट और कुछ सास mixins @font-face घोषणाओं को लिखने के लिए शामिल बना रहा हूं। मुख्य मिश्रण कुछ includeFont(name, weight, style) जैसा होगा।फेंकने कस्टम त्रुटियों/सास

मैं कुछ सैस वेरिएबल (एस) में एक रिकॉर्ड रखूंगा जिसमें वजन और शैलियों वास्तव में उपलब्ध हैं, और इसके बारे में चालाक होने के कारण मुझे लगता है कि मैं मिश्रण लिख सकता हूं ताकि मैं पता लगा सकूं कि मैं कोशिश करता हूं और एक फ़ॉन्ट का अनुरोध करें जो मौजूद नहीं है।

लेकिन जब मैं उस स्थिति का पता लगाने, कैसे मैं एक त्रुटि फेंक कर सकते हैं?

+0

आप प्रलेखन में देखने का प्रयास किया? http://sass-lang.com/documentation/file.SASS_REFERENCE.html#_5 – cimmanon

+1

मैंने किया, लेकिन मैं इस बिट याद किया - धन्यवाद – wheresrhys

उत्तर

5

Sass 3.4.0 के रूप में, वहाँ एक @error निर्देश आप एक गंभीर त्रुटि पैदा करने के लिए उपयोग कर सकते हैं:

$ sass test.scss 
Error: stuff is fubar 
     on line 3 of test.scss 
    Use --trace for backtrace.
: यदि आप खोल में इस संकलन करने का प्रयास करें

$stuff: fubar; 
@if ($stuff == fubar) { 
    @error "stuff is fubar"; 
} 

, आपको निम्नलिखित दिखाई देगा

भी संबंधित वहाँ रहे हैं @warn और @debug निर्देश हैं जो लंबे समय तक के लिए भाषा में किया गया है, इस मामले में उन आपके लिए अधिक उपयोगी है। उदाहरण:

@debug "stuff is happening"; 
@warn "stuff is happening that probably shouldn't be happening"; 

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

संकलित जब:

$ 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; }
संबंधित मुद्दे