Skip to content

Commit 6dd0699

Browse files
committed
Better exception for failed StructMapper deserialization
1 parent 00bc922 commit 6dd0699

File tree

1 file changed

+7
-2
lines changed
  • src/commonMain/kotlin/io/rebble/libpebblecommon/structmapper

1 file changed

+7
-2
lines changed

src/commonMain/kotlin/io/rebble/libpebblecommon/structmapper/StructMapper.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,13 @@ class StructMapper: Mappable {
3535
}
3636

3737
override fun fromBytes(bytes: DataBuffer) {
38-
getStruct().forEach {
39-
it.fromBytes(bytes)
38+
getStruct().forEachIndexed { i: Int, mappable: Mappable ->
39+
try {
40+
mappable.fromBytes(bytes)
41+
}catch (e: Exception) {
42+
throw PacketDecodeException("Unable to deserialize mappable ${mappable::class.simpleName} at index $i (${mappable})", e)
43+
}
44+
4045
}
4146
}
4247

0 commit comments

Comments
 (0)