              component
              (dependencies component)))
 
-(defn- try-action [component system f args]
+(defn- try-action [component system key f args]
   (try (apply f component args)
        (catch Throwable t
-         (throw (ex-info "Error calling function on component"
+         (throw (ex-info (str "Error in component " key
+                              " in system " (.getName (class system))
+                              " calling " f)
                          {:reason ::component-function-threw-exception
                           :function f
                           :component component

(defn- assoc-dependency [system component dependency-key system-key]
  (let [dependency (get system system-key)]
    (when-not dependency
      (throw (ex-info "Missing component dependency"
                      {:reason ::missing-dependency
                       :system-key system-key
                       :dependency-key dependency-key


(defn- get-component [system key]
  (or (get system key)
      (throw (ex-info (str "Missing component " key " from system")
                      {:reason ::missing-component
                       :component-key key
                       :system system}))))
