Skip to content

Commit 64b11b9

Browse files
committed
feat: better error message
1 parent 73f18d7 commit 64b11b9

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

pkg/golinters/misspell.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,10 @@ func appendExtraWords(replacer *misspell.Replacer, extraWords []config.MisspellE
169169
}
170170

171171
if strings.ContainsFunc(word.Typo, func(r rune) bool { return !unicode.IsLetter(r) }) {
172-
return fmt.Errorf("the word in the 'typo' field should only contain letters")
172+
return fmt.Errorf("the word %q in the 'typo' field should only contain letters", word.Typo)
173173
}
174174
if strings.ContainsFunc(word.Correction, func(r rune) bool { return !unicode.IsLetter(r) }) {
175-
return fmt.Errorf("the word in the 'correction' field should only contain letters")
175+
return fmt.Errorf("the word %q in the 'correction' field should only contain letters", word.Correction)
176176
}
177177

178178
extra = append(extra, strings.ToLower(word.Typo), strings.ToLower(word.Correction))

pkg/golinters/misspell_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@ func Test_appendExtraWords_error(t *testing.T) {
6868
Typo: "i'ff",
6969
Correction: "if",
7070
}},
71-
expected: `the word in the 'typo' field should only contain letters`,
71+
expected: `the word "i'ff" in the 'typo' field should only contain letters`,
7272
},
7373
{
7474
desc: "invalid characters in correction",
7575
extraWords: []config.MisspellExtraWords{{
7676
Typo: "iff",
7777
Correction: "i'f",
7878
}},
79-
expected: `the word in the 'correction' field should only contain letters`,
79+
expected: `the word "i'f" in the 'correction' field should only contain letters`,
8080
},
8181
}
8282

0 commit comments

Comments
 (0)