implement decode exception

This commit is contained in:
2026-01-18 21:48:05 +01:00
parent a347bd617c
commit 24c667bc9c
4 changed files with 25 additions and 3 deletions

View File

@@ -1,6 +1,7 @@
package com.infendro.encoding.numeric
import com.infendro.encoding.Encoding
import com.infendro.encoding.exception.IllegalByteException
import com.infendro.encoding.util.BigInt
import com.infendro.encoding.util.log2
import kotlin.math.ceil
@@ -30,8 +31,11 @@ open class NumericEncoding(
var value = BigInt.zero
for (i in 0..<bytes.size) {
val index = alphabet.indexOf(bytes[i])
if (index == -1) throw Exception() //TODO
val byte = bytes[i]
val index = alphabet.indexOf(byte)
if (index == -1) throw IllegalByteException(byte)
value = value.timesAdd(base, index)
}