Skip to content

Commit 75d96b3

Browse files
committed
FEAT: make arraymodel robust to unprintable exceptions messages
sometimes the exception message itself contains unprintable data (e.g. unicode string with characters which cannot be encoded to the stderr encoding)
1 parent 6418e81 commit 75d96b3

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

larray_editor/arraymodel.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,8 +491,15 @@ def _get_current_data(self):
491491
raw_data = self._fetch_data(self.h_offset, self.v_offset,
492492
h_stop, v_stop)
493493
except Exception as e:
494-
logger.error(f"could not fetch data from adapter:\n"
495-
f"{''.join(format_exception(e))}")
494+
try:
495+
logger.error(f"could not fetch data from adapter:\n"
496+
f"{''.join(format_exception(e))}")
497+
except Exception:
498+
# sometimes the exception message itself contains unprintable
499+
# data (e.g. unicode string with characters which cannot be
500+
# encoded to the stderr encoding)
501+
logger.error("could not fetch data from adapter "
502+
"(and cannot log exception)")
496503
raw_data = np.array([[]])
497504
if not isinstance(raw_data, dict):
498505
raw_data = {'values': raw_data}

0 commit comments

Comments
 (0)