Skip to content

Commit 68a416a

Browse files
jeffwidmandpkp
authored andcommitted
Raise better struct pack/unpack errors (#1320)
1 parent 04fb37f commit 68a416a

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

kafka/protocol/types.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,20 @@
88
def _pack(f, value):
99
try:
1010
return pack(f, value)
11-
except error:
12-
raise ValueError(error)
11+
except error as e:
12+
raise ValueError("Error encountered when attempting to convert value: "
13+
"{} to struct format: '{}', hit error: {}"
14+
.format(value, f, e))
1315

1416

1517
def _unpack(f, data):
1618
try:
1719
(value,) = unpack(f, data)
1820
return value
19-
except error:
20-
raise ValueError(error)
21+
except error as e:
22+
raise ValueError("Error encountered when attempting to convert value: "
23+
"{} to struct format: '{}', hit error: {}"
24+
.format(value, f, e))
2125

2226

2327
class Int8(AbstractType):

0 commit comments

Comments
 (0)