dump_errors: better handling of unknown errors

This commit is contained in:
Samuel Sadok
2020-08-05 16:32:42 +02:00
parent 0d018fc710
commit 30bc561231
+4 -7
View File
@@ -89,13 +89,10 @@ def dump_errors(odrv, clear=False):
if (remote_obj.error != 0):
foundError = False
print(prefix + _VT100Colors['red'] + "Error(s):" + _VT100Colors['default'])
errorcodes_tup = [(name, val) for name, val in errorcodes.items() if 'ERROR_' in name]
for codename, codeval in errorcodes_tup:
if remote_obj.error & codeval != 0:
foundError = True
print(" " + codename)
if not foundError:
print(" " + 'UNKNOWN ERROR!')
errorcodes_dict = {val: name for name, val in errorcodes.items() if 'ERROR_' in name}
for bit in range(64):
if remote_obj.error & (1 << bit) != 0:
print(" " + errorcodes_dict.get((1 << bit), 'UNKNOWN ERROR: 0x{:08X}'.format(1 << bit)))
if clear:
remote_obj.error = 0
else: