Skip to content

Commit

Permalink
Better exception for failed StructMapper deserialization
Browse files Browse the repository at this point in the history
  • Loading branch information
crc-32 committed Feb 16, 2021
1 parent 00bc922 commit 6dd0699
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,13 @@ class StructMapper: Mappable {
}

override fun fromBytes(bytes: DataBuffer) {
getStruct().forEach {
it.fromBytes(bytes)
getStruct().forEachIndexed { i: Int, mappable: Mappable ->
try {
mappable.fromBytes(bytes)
}catch (e: Exception) {
throw PacketDecodeException("Unable to deserialize mappable ${mappable::class.simpleName} at index $i (${mappable})", e)
}

}
}

Expand Down

0 comments on commit 6dd0699

Please sign in to comment.