Skip to content

Commit f552d01

Browse files
committed
Fix the error message when there are several variable-length fields
Fixes #359
1 parent cc8121a commit f552d01

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

core/common/src/internal/format/parser/ParserOperation.kt

+6-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,12 @@ internal class NumberSpanParserOperation<Output>(
5050

5151
init {
5252
require(consumers.all { (it.length ?: Int.MAX_VALUE) > 0 })
53-
require(consumers.count { it.length == null } <= 1)
53+
require(consumers.count { it.length == null } <= 1) {
54+
val fieldNames = consumers.filter { it.length == null }.map { it.whatThisExpects }
55+
"At most one variable-length numeric field in a row is allowed, but got several: $fieldNames. " +
56+
"Parsing is undefined: for example, with variable-length month number " +
57+
"and variable-length day of month, '111' can be parsed as Jan 11th or Nov 1st."
58+
}
5459
}
5560

5661
private val whatThisExpects: String

0 commit comments

Comments
 (0)