From 9a97681a3cab227242396de8deb76484c2642842 Mon Sep 17 00:00:00 2001 From: "dmitri.sotnikov@gmail.com" Date: Sun, 6 Jan 2019 10:57:03 -0500 Subject: [PATCH] added and error check when fetching Mastodon timeline --- mastodon-bot.cljs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mastodon-bot.cljs b/mastodon-bot.cljs index cd06b73..11242f6 100755 --- a/mastodon-bot.cljs +++ b/mastodon-bot.cljs @@ -119,7 +119,11 @@ (post-status status-text (not-empty ids))))) (defn get-mastodon-timeline [callback] - (.then (.get mastodon-client "timelines/home" #js {}) #(-> % .-data js->edn callback))) + (.then (.get mastodon-client "timelines/home" #js {}) + #(let [response (-> % .-data js->edn)] + (if-let [error (:error response)] + (exit-with-error error) + (callback response))))) (defn post-items [last-post-time items] (doseq [{:keys [text media-links]} (->> items