implement decode exception
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user