how to trap a "too many nodes" error

Can we code a solution for a selection that is too complex for a function?

e.g.,  CorelDRAW seems to go into an endless loop when asked to to a Contour on a selection with thousands of nodes; doesn't remove itself from memory but requires Task Manager to shut it down and try again.