Defensive: try/except around decode in _row_to_message
Decode errors now log to stderr instead of crashing the entire API response. This prevents a single malformed message from hiding all subsequent messages in the same query.
This commit is contained in:
1 parent
e211dd91bc
commit
41b5c0218e
1 file changed
+5
@@ -177,6 +177,11 @@ class Database:
|
|||||||
'flags': row[5],
|
'flags': row[5],
|
||||||
}
|
}
|
||||||
if row[3] in ('tpdu', 'change', 'fidi', 'atr', 'pps') and data_blob:
|
if row[3] in ('tpdu', 'change', 'fidi', 'atr', 'pps') and data_blob:
|
||||||
|
try:
|
||||||
from .decode import decode_sniff_msg
|
from .decode import decode_sniff_msg
|
||||||
msg['decoded'] = decode_sniff_msg(data_blob, row[3])
|
msg['decoded'] = decode_sniff_msg(data_blob, row[3])
|
||||||
|
except Exception as e:
|
||||||
|
import sys
|
||||||
|
print(f'Decode error for msg {row[0]} ({row[3]}, {len(data_blob)} bytes): {e}',
|
||||||
|
file=sys.stderr)
|
||||||
return msg
|
return msg
|
||||||
Reference in new issue
Block a user