 (def active-slice-sequence (atom nil))
 
 (def pixel-type-depths {"GRAY8" 1 "GRAY16" 2 "RGB32" 4 "RGB64" 8})
+
+(defn check-for-serious-error []
+  (when (.. MMStudioMainFrame seriousErrorReported_ get)
+    (swap! state :stop true)))
 
 ;; time
 

        bursts-per-camera-channel (vec (repeat camera-channel-count burst-events))]
    (doall
      (loop [burst-seqs bursts-per-camera-channel i 0]
        (if (and (not (@state :stop))
                 (not (apply = nil burst-seqs))
                 (or (pos? (core getRemainingImageCount))


(defn execute [event-fns]
  (doseq [event-fn event-fns :while (not (:stop @state))]
    (check-for-serious-error)
    (try (event-fn) (catch Throwable e (ReportingUtils/logError e)))
    (await-resume)))

