Skip to content

Commit

Permalink
refactor: use contextualDecodingException when failing to decode a …
Browse files Browse the repository at this point in the history
…char
  • Loading branch information
HatoYuze committed Jan 31, 2025
1 parent c98c587 commit 942b838
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,15 @@ public class YamlBuilder internal constructor(
CHAR_DOUBLE_QUOTATION,

/**
* Convert all [Char]s to their corresponding Unicode code points [Int]
* Encode [Char]s as their [code][Char.code] in integer.
* _(It will work like [Byte])_
*
* For example, the character 'A' will be converted to 65
*
* It will work like [Byte]
*/
CHAR_UNICODE_CODE,

/**
* Directly use the character content of [Char]
* Don't quote any [Char].
*
* When escaping is necessary, it defaults to using [CHAR_SINGLE_QUOTATION]
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@ internal class YamlDecoder(
this.debuggingLogDecoder(descriptor, index)?.let {
when {
it.length == 1 -> it.first()
it.any { !it.isDigit() } -> error("too many chars for a char: $it")
it.any { !it.isDigit() } -> throw contextualDecodingException("too many chars for a char: $it")
else -> withIntegerValue("char", descriptor, index).limitToChar()
}
} ?: checkNonStrictNullability(descriptor, index)
Expand Down

0 comments on commit 942b838

Please sign in to comment.