static FixedRateTimer doEvery_stopOnException(double initialSeconds default delaySeconds, double delaySeconds, Runnable r, Runnable onStop default null) { if (r == null) null; FixedRateTimer timer = new(shorten(programID() + ": " + r, 80)); Runnable r2 = r { try { r.run(); } catch print e { print("Cancelling timer due to error."); timer.cancel(); pcallF(onStop); } }; timer.scheduleAtFixedRate( smartTimerTask(r2, timer, toMS_int(delaySeconds)), toMS_int(initialSeconds), toMS_int(delaySeconds)); ret timer; }