         (def acq-sequence acq-seq)
         (execute (mapcat #(make-event-fns % out-queue) acq-seq)))
       (catch Throwable t
+             (def acq-error t)
              (ReportingUtils/showError t "Acquisition failed."))
       (finally
         (when cleanup?
           (cleanup))
-        (.put out-queue TaggedImageQueue/POISON)))))
+        (.put out-queue TaggedImageQueue/POISON))))
 
 ;; generic metadata
 

    {:pix (.pix tagged-image)
     :tags (json-to-data (.tags tagged-image))}))

(defn make-multicamera-channel [raw-channel-index camera-channel]
  (+ camera-channel (* (core getNumberOfCameraChannels) (or raw-channel-index 0))))

(defn make-multicamera-events [event]
  (let [num-camera-channels (core getNumberOfCameraChannels)
        camera-channel-names (get-camera-channel-names)]
    (for [camera-channel (range num-camera-channels)]
      (-> event
          (update-in [:channel-index] make-multicamera-channel camera-channel)
          (update-in [:channel :name] super-channel-name (camera-channel-names camera-channel))
          (assoc :camera-channel-index camera-channel)
          (assoc :camera (camera-channel-names camera-channel))))))


(defn stop []
  (when-let [acq-thread (:acq-thread (.state last-acq))]
    (.stop acq-thread)))

(defn drain-queue [blocking-queue]
  (future (loop [i 0]
            (let [obj (.take blocking-queue)]
              (when (zero? (mod i 100))
                (println i (core getRemainingImageCount)))
              (when (not= obj blocking-queue)
                (recur (inc i)))))))

(defn null-queue []
  (doto (LinkedBlockingQueue.)
    drain-queue))

