coredevice/comm_kernel: map exceptions to correct names

This commit is contained in:
abdul124 2024-08-19 11:46:30 +08:00 committed by Sébastien Bourdeauducq
parent 33d5002f39
commit 09128f87e6
1 changed files with 5 additions and 3 deletions

View File

@ -3,6 +3,7 @@ import logging
import traceback import traceback
import numpy import numpy
import socket import socket
import builtins
from enum import Enum from enum import Enum
from fractions import Fraction from fractions import Fraction
from collections import namedtuple from collections import namedtuple
@ -616,9 +617,10 @@ class CommKernel:
self._write_int32(embedding_map.store_str(function)) self._write_int32(embedding_map.store_str(function))
else: else:
exn_type = type(exn) exn_type = type(exn)
if exn_type in (ZeroDivisionError, ValueError, IndexError, RuntimeError) or \ if exn_type in builtins.__dict__.values():
hasattr(exn, "artiq_builtin"): name = "0:{}".format(exn_type.__qualname__)
name = "0:{}".format(exn_type.__name__) elif hasattr(exn, "artiq_builtin"):
name = "0:{}.{}".format(exn_type.__module__, exn_type.__qualname__)
else: else:
exn_id = embedding_map.store_object(exn_type) exn_id = embedding_map.store_object(exn_type)
name = "{}:{}.{}".format(exn_id, name = "{}:{}.{}".format(exn_id,