Skip to content

Commit cfdd274

Browse files
committed
Add more useful error messages
1 parent efa88d2 commit cfdd274

File tree

8 files changed

+31
-21
lines changed

8 files changed

+31
-21
lines changed

lib/util/check-bullet.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ function checkBullet(context) {
55

66
if (marker !== '*' && marker !== '+' && marker !== '-') {
77
throw new Error(
8-
'Cannot serialize items with `' + marker + '`, expected `*`, `+`, or `-`'
8+
'Cannot serialize items with `' +
9+
marker +
10+
'` for `options.bullet`, expected `*`, `+`, or `-`'
911
)
1012
}
1113

lib/util/check-emphasis.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ function checkEmphasis(context) {
55

66
if (marker !== '*' && marker !== '_') {
77
throw new Error(
8-
'Cannot serialize emphasis with `' + marker + '`, expected `*`, or `_`'
8+
'Cannot serialize emphasis with `' +
9+
marker +
10+
'` for `options.emphasis`, expected `*`, or `_`'
911
)
1012
}
1113

lib/util/check-list-item-indent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function checkListItemIndent(context) {
1111
throw new Error(
1212
'Cannot serialize items with `' +
1313
style +
14-
'`, expected `tab`, `one`, or `mixed`'
14+
'` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`'
1515
)
1616
}
1717

lib/util/check-quote.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ function checkQuote(context) {
55

66
if (marker !== '"' && marker !== "'") {
77
throw new Error(
8-
'Cannot serialize title with `' + marker + '`, expected `"`, or `\'`'
8+
'Cannot serialize title with `' +
9+
marker +
10+
'` for `options.quote`, expected `"`, or `\'`'
911
)
1012
}
1113

lib/util/check-rule-repeat.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function checkRule(context) {
77
throw new Error(
88
'Cannot serialize rules with repetition `' +
99
repetition +
10-
'`, expected `3` or more'
10+
'` for `options.ruleRepetition`, expected `3` or more'
1111
)
1212
}
1313

lib/util/check-rule.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ function checkRule(context) {
55

66
if (marker !== '*' && marker !== '-' && marker !== '_') {
77
throw new Error(
8-
'Cannot serialize rules with `' + marker + '`, expected `*`, `-`, or `_`'
8+
'Cannot serialize rules with `' +
9+
marker +
10+
'` for `options.rule`, expected `*`, `-`, or `_`'
911
)
1012
}
1113

lib/util/check-strong.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ function checkStrong(context) {
55

66
if (marker !== '*' && marker !== '_') {
77
throw new Error(
8-
'Cannot serialize strong with `' + marker + '`, expected `*`, or `_`'
8+
'Cannot serialize strong with `' +
9+
marker +
10+
'` for `options.strong`, expected `*`, or `_`'
911
)
1012
}
1113

test.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -799,8 +799,8 @@ test('definition', function (t) {
799799
function () {
800800
to({type: 'definition', identifier: 'a', title: 'b'}, {quote: '.'})
801801
},
802-
/Cannot serialize title with `\.`, expected `"`, or `'`/,
803-
'should throw on when given an incorrect `emphasis`'
802+
/Cannot serialize title with `\.` for `options\.quote`, expected `"`, or `'`/,
803+
'should throw on when given an incorrect `quote`'
804804
)
805805

806806
t.end()
@@ -813,7 +813,7 @@ test('emphasis', function (t) {
813813
function () {
814814
to({type: 'emphasis'}, {emphasis: '?'})
815815
},
816-
/Cannot serialize emphasis with `\?`, expected `\*`, or `_`/,
816+
/Cannot serialize emphasis with `\?` for `options\.emphasis`, expected `\*`, or `_`/,
817817
'should throw on when given an incorrect `emphasis`'
818818
)
819819

@@ -1053,8 +1053,8 @@ test('image', function (t) {
10531053
function () {
10541054
to({type: 'image', title: 'a'}, {quote: '.'})
10551055
},
1056-
/Cannot serialize title with `\.`, expected `"`, or `'`/,
1057-
'should throw on when given an incorrect `emphasis`'
1056+
/Cannot serialize title with `\.` for `options\.quote`, expected `"`, or `'`/,
1057+
'should throw on when given an incorrect `quote`'
10581058
)
10591059

10601060
t.end()
@@ -1411,8 +1411,8 @@ test('link', function (t) {
14111411
function () {
14121412
to({type: 'link', title: 'b'}, {quote: '.'})
14131413
},
1414-
/Cannot serialize title with `\.`, expected `"`, or `'`/,
1415-
'should throw on when given an incorrect `emphasis`'
1414+
/Cannot serialize title with `\.` for `options\.quote`, expected `"`, or `'`/,
1415+
'should throw on when given an incorrect `quote`'
14161416
)
14171417

14181418
t.end()
@@ -1975,7 +1975,7 @@ test('listItem', function (t) {
19751975
function () {
19761976
to({type: 'listItem'}, {bullet: '.'})
19771977
},
1978-
/Cannot serialize items with `\.`, expected `\*`, `\+`, or `-`/,
1978+
/Cannot serialize items with `\.` for `options\.bullet`, expected `\*`, `\+`, or `-`/,
19791979
'should throw on an incorrect bullet'
19801980
)
19811981

@@ -2063,7 +2063,7 @@ test('listItem', function (t) {
20632063
function () {
20642064
to({type: 'listItem'}, {listItemIndent: 'x'})
20652065
},
2066-
/Cannot serialize items with `x`, expected `tab`, `one`, or `mixed`/,
2066+
/Cannot serialize items with `x` for `options\.listItemIndent`, expected `tab`, `one`, or `mixed`/,
20672067
'should throw on an incorrect `listItemIndent`'
20682068
)
20692069

@@ -2102,8 +2102,8 @@ test('strong', function (t) {
21022102
function () {
21032103
to({type: 'strong'}, {strong: '?'})
21042104
},
2105-
/Cannot serialize strong with `\?`, expected `\*`, or `_`/,
2106-
'should throw on when given an incorrect `emphasis`'
2105+
/Cannot serialize strong with `\?` for `options\.strong`, expected `\*`, or `_`/,
2106+
'should throw on when given an incorrect `strong`'
21072107
)
21082108

21092109
t.equal(
@@ -2147,7 +2147,7 @@ test('thematic break', function (t) {
21472147
function () {
21482148
to({type: 'thematicBreak'}, {rule: '.'})
21492149
},
2150-
/Cannot serialize rules with `.`, expected `\*`, `-`, or `_`/,
2150+
/Cannot serialize rules with `.` for `options\.rule`, expected `\*`, `-`, or `_`/,
21512151
'should throw on when given an incorrect `rule`'
21522152
)
21532153

@@ -2161,8 +2161,8 @@ test('thematic break', function (t) {
21612161
function () {
21622162
to({type: 'thematicBreak'}, {ruleRepetition: 2})
21632163
},
2164-
/Cannot serialize rules with repetition `2`, expected `3` or more/,
2165-
'should throw on when given an incorrect `rule`'
2164+
/Cannot serialize rules with repetition `2` for `options\.ruleRepetition`, expected `3` or more/,
2165+
'should throw on when given an incorrect `ruleRepetition`'
21662166
)
21672167

21682168
t.equal(

0 commit comments

Comments
 (0)