Skip to content

Commit

Permalink
Improve error handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
whilo committed Apr 13, 2024
1 parent 5ddf9d8 commit eb15692
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
9 changes: 6 additions & 3 deletions src/ie/simm/runtimes/telegram.clj
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@
(put? S next-in (assoc m
:type :ie.simm.languages.chat/send-text-reply
:response (try (t/send-text (:telegram-bot-token config) chat-id msg)
(catch Exception e
;; TODO bug in slingshot forces us to catch Throwable for HTTP errors,
;; https://github.com/scgilardi/slingshot/issues/60
;; this can also be resolved by refactoring morse to be more lean
(catch Throwable e
(debug "error sending telegram message:" e)
e))))
(recur (<? S send-text))))
Expand All @@ -123,7 +126,7 @@
:type :ie.simm.languages.chat/send-photo-reply
:response (try
(t/send-photo (:telegram-bot-token config) chat-id url)
(catch Exception e
(catch Throwable e
(debug "error sending telegram photo:" e)
e))))
(recur (<? S send-photo))))
Expand All @@ -135,7 +138,7 @@
:type :ie.simm.languages.chat/send-document-reply
:response (try
(t/send-document (:telegram-bot-token config) chat-id url)
(catch Exception e
(catch Throwable e
(debug "error sending telegram document:" e)
e))))
(recur (<? S send-document))))
Expand Down
5 changes: 2 additions & 3 deletions src/ie/simm/simmie.clj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(ns ie.simm.simmie
(:require [taoensso.timbre :as log]
[taoensso.timbre.appenders.core :as appenders]
[superv.async :refer [S go-try <? <??] :as sasync]
[superv.async :refer [S go-try <? <?? on-abort] :as sasync]
[ie.simm.http :refer [ring-handler]]
[ring.adapter.jetty :refer [run-jetty]]
[clojure.core.async :refer [chan close!]]
Expand Down Expand Up @@ -30,8 +30,7 @@
(swap! peer assoc-in [:http :server] server)
(log/info "Server started.")
;; this only unblocks on crash
(<? S (chan))
(.stop server))))
(on-abort S (.stop server)))))
:delay (* 10 1000)
:log-fn (fn [level msg] (log/log level msg)))
(log/info "Server started.")
Expand Down

0 comments on commit eb15692

Please sign in to comment.