L3F.WIN

Github及Hexo的使用

0%

学习stylus【23】错误报告(Error Reporting)

错误报告(Error Reporting)

Stylus内置梦幻般的错误报告,针对语法、解析以及计算错误,完整的堆栈跟踪,行号和文件名。

解析错误

解析错误例子:

1
2
3
4
5
6
7
8
9
10
11
12
body
form input
== padding 5px
=>
ParseError: test.styl:3:16
1| body
2| form input
3| == padding 5px
---------------------^
4|

illegal unary "==", missing left-hand operand

计算错误

这种“运行”或计算错误类似于传递字符串给border-radius(),而不是单位值

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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'
=>
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)