         namespace (thing->namespace thing)
         _         (assert namespace)
         handle    (thing->handle config :else namespace)]
-    (for [d     (.listFiles handle)
-          :when (.isDirectory d)]
-      (->T :def namespace (.getName d)))))
+    (if (.isDirectory handle)
+      (for [d     (.listFiles handle)
+            :when (.isDirectory d)]
+        (->T :def namespace (.getName d)))
+      (throw-e "No such namespace "
+               (:uri thing)))))
 
 ;; FIXME: this should really be handled in data generation not in data use
 (defn- normalize-version [x]

        version (thing->version thing)
        _       (assert version)
        handle  (thing->handle config :else version)]
    (for [d     (.listFiles handle)
          :when (.isDirectory d)]
      (->T :namespace version (.getName d)))))

(defmethod api/list-defs :filesystem [config thing]
  (let [thing     (ensure-thing thing)

            [clojure.edn :as edn]
            [version-clj.core :as semver]))

(defmacro throw-e [& forms]
  `(throw (Exception. (str ~@forms))))

;; List things
;;--------------------
(defmethod api/list-groups :filesystem [config]
  (let [handle (io/file (-> config :datastore :docs))]
    (if (.isDirectory handle)
      (for [d     (.listFiles handle)
            :when (.isDirectory d)]
        (->T :group nil (.getName d)))
      (throw
       (Exception.
        "Could not find store directory")))))

(defmethod api/list-artifacts :filesystem [config thing]
  (let [thing  (ensure-thing thing)
        thing  (thing->group thing)
        _      (assert thing)
        handle (thing->handle config :else thing)]
    (if (.isDirectory handle)
      (for [d     (.listFiles handle)
            :when (.isDirectory d)]
        (->T :artifact thing (.getName d)))
      (throw-e "No such group "
               (:uri thing)))))

(defmethod api/list-versions :filesystem [config thing]
  (let [thing    (ensure-thing thing)
        artifact (thing->artifact thing)
        _        (assert artifact)
        handle   (thing->handle config :else artifact)]
    (if (.isDirectory handle)
      (->> (for [d     (reverse (sort (.listFiles handle)))
               :when (.isDirectory d)]
           (->T :version artifact (.getName d)))
         (sort-by :name)
         reverse)
      (throw-e  "No such artifact "
                (:uri thing)))))

(defmethod api/list-namespaces :filesystem [config thing]
  (let [thing   (ensure-thing thing)
