(defn process-handler [{:keys [files paths] :as spec}]
(assoc spec :handler
(catch-errors
(fn [ctx {:keys [file kind] :as e}]
(let [path (-> file .toPath)]
(if (and
(some #(.startsWith path %) paths)
(or (empty? files)
(some (partial = file) files))
(or (not (:filter spec))
((:filter spec) ctx e)))
(do
((:handler spec) ctx e))
ctx))))))