diff --git a/recipes/error-handling/src/client/app/ui.cljs b/recipes/error-handling/src/client/app/ui.cljs index 4831a7e..5441424 100644 --- a/recipes/error-handling/src/client/app/ui.cljs +++ b/recipes/error-handling/src/client/app/ui.cljs @@ -6,7 +6,9 @@ (defui ^:once Child static om/IQuery ;; you can query for the server-error using a link from any component that composes to root - (query [_] [[:untangled/server-error '_] :ui/button-disabled]) + (query [_] [[:untangled/server-error '_] :ui/button-disabled :untangled/read-error]) + static om/Ident + (ident [_ _] [:child/by-id :singleton]) Object (render [this] (let [{:keys [untangled/server-error ui/button-disabled]} (om/props this)] @@ -16,6 +18,8 @@ (dom/button #js {:onClick #(om/transact! this '[(my/mutation) (tx/fallback {:action button/disable})]) :disabled button-disabled} "Click me for error!") + (dom/button #js {:onClick #(df/load-field this :untangled/read-error)} + "Click me for other error!") (dom/div nil (str server-error)))))) (def ui-child (om/factory Child)) diff --git a/recipes/error-handling/src/server/app/api.clj b/recipes/error-handling/src/server/app/api.clj index dea4dc2..a1e1798 100644 --- a/recipes/error-handling/src/server/app/api.clj +++ b/recipes/error-handling/src/server/app/api.clj @@ -13,6 +13,9 @@ (defmethod apimutate :default [e k p] (timbre/error "Unrecognized mutation " k)) +(defmethod api-read :child/by-id [{:keys [ast]} _ _] + {:value (throw (ex-info "other read error" {}))}) + (defmethod api-read :default [{:keys [ast]} _ _] (timbre/error "Unrecognized query " (op/ast->expr ast)) ;; Bug in untangled server requires the error response bodies for reads to be manually encoded as json, will fix soon