implement decode exception
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
package com.infendro.encoding.exception
|
||||
|
||||
abstract class DecodeException : Exception() {
|
||||
abstract override val message: String
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.infendro.encoding.exception
|
||||
|
||||
class IllegalByteException(
|
||||
val byte: Byte,
|
||||
) : DecodeException() {
|
||||
override val message: String
|
||||
get() {
|
||||
val hex = "0x${byte.toHexString().padStart(2, '0')}"
|
||||
val char = "'${byte.toInt().toChar()}'"
|
||||
return "Illegal byte $hex ($char)."
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user