@@ -26,6 +26,7 @@ import io.matthewnelson.encoding.core.Decoder
2626import io.matthewnelson.encoding.core.Encoder
2727import io.matthewnelson.encoding.core.EncoderDecoder
2828import io.matthewnelson.encoding.core.EncodingException
29+ import io.matthewnelson.encoding.core.MalformedEncodingException
2930import io.matthewnelson.encoding.core.util.DecoderInput
3031import io.matthewnelson.encoding.core.util.FeedBuffer
3132import io.matthewnelson.encoding.core.util.LineBreakOutFeed
@@ -122,7 +123,7 @@ public sealed class Base32<C: EncoderDecoder.Config>(config: C): EncoderDecoder<
122123 * allowed but ignored) during decoding operations. This is non-compliant with
123124 * the Crockford spec.
124125 *
125- * If `false`, an [EncodingException ] will be thrown.
126+ * If `false`, a [MalformedEncodingException ] will be thrown.
126127 * */
127128 public fun isLenient (enable : Boolean ): Builder = apply { _isLenient = enable }
128129
@@ -260,7 +261,7 @@ public sealed class Base32<C: EncoderDecoder.Config>(config: C): EncoderDecoder<
260261 } else {
261262 " Missing check symbol. Expected[$checkSymbol ]"
262263 }
263- throw EncodingException (msg)
264+ throw MalformedEncodingException (msg)
264265 } else {
265266 outSize--
266267 }
@@ -525,7 +526,7 @@ public sealed class Base32<C: EncoderDecoder.Config>(config: C): EncoderDecoder<
525526 * allowed but ignored) during decoding operations. This is non-compliant with
526527 * `RFC 4648`.
527528 *
528- * If `false`, an [EncodingException ] will be thrown.
529+ * If `false`, a [MalformedEncodingException ] will be thrown.
529530 * */
530531 public fun isLenient (enable : Boolean ): Builder = apply { _isLenient = enable }
531532
@@ -866,7 +867,7 @@ public sealed class Base32<C: EncoderDecoder.Config>(config: C): EncoderDecoder<
866867 * allowed but ignored) during decoding operations. This is non-compliant with
867868 * `RFC 4648`.
868869 *
869- * If `false`, an [EncodingException ] will be thrown.
870+ * If `false`, a [MalformedEncodingException ] will be thrown.
870871 * */
871872 public fun isLenient (enable : Boolean ): Builder = apply { _isLenient = enable }
872873
@@ -1143,7 +1144,7 @@ public sealed class Base32<C: EncoderDecoder.Config>(config: C): EncoderDecoder<
11431144 val code = input.code
11441145 val diff = code.decodeDiff()
11451146 if (diff == 0 ) {
1146- throw Diff0EncodingException (" Char[$input ] is not a valid Base32 character" )
1147+ throw MalformedEncodingException (" Char[$input ] is not a valid ${name()} character" )
11471148 }
11481149
11491150 if (iBuf < 7 ) {
@@ -1463,7 +1464,7 @@ public sealed class Base32<C: EncoderDecoder.Config>(config: C): EncoderDecoder<
14631464 if (isCheckSymbolSet) {
14641465 // If the set checkSymbol was not intended, it's only valid as the
14651466 // very last character and the previous update call was invalid.
1466- throw EncodingException (" CheckSymbol[${_config .checkSymbol} ] was set" )
1467+ throw MalformedEncodingException (" CheckSymbol[${_config .checkSymbol} ] was set" )
14671468 }
14681469
14691470 // Crockford allows for insertion of hyphens, which are to be ignored.
@@ -1472,7 +1473,7 @@ public sealed class Base32<C: EncoderDecoder.Config>(config: C): EncoderDecoder<
14721473 try {
14731474 super .consumeProtected(input)
14741475 hadInput = true
1475- } catch (e: Diff0EncodingException ) {
1476+ } catch (e: MalformedEncodingException ) {
14761477 // decodeDiff returned 0. See if it's a check symbol.
14771478 if (! input.isCheckSymbol()) throw e
14781479
@@ -1483,14 +1484,14 @@ public sealed class Base32<C: EncoderDecoder.Config>(config: C): EncoderDecoder<
14831484 }
14841485
14851486 // Have the wrong check symbol
1486- throw EncodingException (" Char[$input ] IS a check symbol, but did not match config's CheckSymbol[${_config .checkSymbol} ]" , e)
1487+ throw MalformedEncodingException (" Char[$input ] IS a check symbol, but did not match config's CheckSymbol[${_config .checkSymbol} ]" , e)
14871488 }
14881489 }
14891490
14901491 override fun doFinalProtected () {
14911492 if (isClosed() || _config .finalizeWhenFlushed) {
14921493 if (hadInput && _config .checkSymbol != null && ! isCheckSymbolSet) {
1493- throw EncodingException (" Missing check symbol. Expected[${_config .checkSymbol} ]" )
1494+ throw MalformedEncodingException (" Missing check symbol. Expected[${_config .checkSymbol} ]" )
14941495 }
14951496 isCheckSymbolSet = false
14961497 hadInput = false
@@ -1559,10 +1560,6 @@ public sealed class Base32<C: EncoderDecoder.Config>(config: C): EncoderDecoder<
15591560 }
15601561 }
15611562
1562- // Thrown by AbstractDecoderFeed when decodeDiff returns 0.
1563- // Is for Crockford in order to check input for a check symbol.
1564- private class Diff0EncodingException (message : String ): EncodingException(message)
1565-
15661563 private class HyphenOutFeed (
15671564 private val interval : Byte ,
15681565 private val out : Encoder .OutFeed ,
0 commit comments