A decorator that create a callable which can be passed to :func:`AddVectoredExceptionHandler`
| 327 | |
| 328 | |
| 329 | class VectoredException(object): |
| 330 | """A decorator that create a callable which can be passed to :func:`AddVectoredExceptionHandler`""" |
| 331 | func_type = ctypes.WINFUNCTYPE(ctypes.c_uint, ctypes.POINTER(EEXCEPTION_POINTERS)) |
| 332 | |
| 333 | def __new__(cls, func): |
| 334 | self = object.__new__(cls) |
| 335 | self.func = func |
| 336 | v = self.func_type(self.decorator) |
| 337 | v.self = self |
| 338 | return v |
| 339 | |
| 340 | def decorator(self, exception_pointers): |
| 341 | try: |
| 342 | return self.func(exception_pointers) |
| 343 | except BaseException as e: |
| 344 | import traceback |
| 345 | print("Ignored Python Exception in Vectored Exception: {0}".format(e)) |
| 346 | traceback.print_exc() |
| 347 | return windef.EXCEPTION_CONTINUE_SEARCH |
| 348 | |
| 349 | |
| 350 | class VectoredExceptionHandler(object): |