Appearance
错误报告
¥Error Reporting
Stylus 具有出色的内置错误报告功能,可用于语法、解析和评估错误,包括堆栈跟踪、行号和文件名。
¥Stylus has fantastic error reporting built-in for syntax, parse, and evaluation errors—complete with stack traces, line numbers, and filenames.
解析错误
¥Parse Error
解析错误示例:
¥Parse error example:
     body
       form input
         == padding 5px
     body
       form input
         == padding 5px
产量:
¥Yielding:
ParseError: test.styl:3:16
  1| body
  2|    form input
  3|      == padding 5px
---------------------^
  4|
illegal unary "==", missing left-hand operand
ParseError: test.styl:3:16
  1| body
  2|    form input
  3|      == padding 5px
---------------------^
  4|
illegal unary "==", missing left-hand operand
评估错误
¥Evaluation Error
这个 "runtime" 或评估错误是由于将字符串传递给 border-radius() 而不是预期的 Unit (通过使用我们的助手 ensure(n, 'unit'))引起的。
¥This "runtime" or evaluation error is caused by passing a string to border-radius(), instead of the expected Unit (by using our helper ensure(n, 'unit')).
ensure(val, type)
  unless val is a type
    error('expected a ' + type + ', but got ' + typeof(val))
border-radius(n)
  ensure(n, 'unit')
  -webkit-border-radius n
  -moz-border-radius n
  border-radius n
body
  border-radius '5px'
ensure(val, type)
  unless val is a type
    error('expected a ' + type + ', but got ' + typeof(val))
border-radius(n)
  ensure(n, 'unit')
  -webkit-border-radius n
  -moz-border-radius n
  border-radius n
body
  border-radius '5px'
产量:
¥Yielding:
Error: test.styl:3:62
  1| ensure(val, type)
  2|     unless val is a type
  3|       error('expected a ' + type + ', but got ' + typeof(val))
-------------------------------------------------------------------^
  4|
  5| border-radius(n)
  6|   ensure(n, 'unit')
expected a unit, but got string
    at ensure() (test.styl:2:17)
    at border-radius() (test.styl:6:16)
    at "body" (test.styl:10:18)
Error: test.styl:3:62
  1| ensure(val, type)
  2|     unless val is a type
  3|       error('expected a ' + type + ', but got ' + typeof(val))
-------------------------------------------------------------------^
  4|
  5| border-radius(n)
  6|   ensure(n, 'unit')
expected a unit, but got string
    at ensure() (test.styl:2:17)
    at border-radius() (test.styl:6:16)
    at "body" (test.styl:10:18)