From a2e4014b56d9f3e5d74270564f4c32ff60ee2e3e Mon Sep 17 00:00:00 2001 From: Nicolas Perriault Date: Tue, 25 Apr 2017 17:27:21 +0200 Subject: [PATCH] Add error logging to WS errors. --- src/Model.elm | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/Model.elm b/src/Model.elm index 514a745..9316056 100644 --- a/src/Model.elm +++ b/src/Model.elm @@ -540,25 +540,29 @@ update msg model = { model | notifications = [], errors = (errorText error) :: model.errors } ! [] NewWebsocketUserMessage message -> - case (Mastodon.decodeWebSocketMessage message) of - Mastodon.EventError error -> - { model | errors = error :: model.errors } ! [] + let + logError label error message = + Debug.log (label ++ " WS error: " ++ error) message + in + case (Mastodon.decodeWebSocketMessage message) of + Mastodon.EventError error -> + { model | errors = (logError "EventError" error message) :: model.errors } ! [] - Mastodon.NotificationResult result -> - case result of - Ok notification -> - { model | notifications = Mastodon.addNotificationToAggregates notification model.notifications } ! [] + Mastodon.NotificationResult result -> + case result of + Ok notification -> + { model | notifications = Mastodon.addNotificationToAggregates notification model.notifications } ! [] - Err error -> - { model | errors = error :: model.errors } ! [] + Err error -> + { model | errors = (logError "NotificationResult" error message) :: model.errors } ! [] - Mastodon.StatusResult result -> - case result of - Ok status -> - { model | userTimeline = status :: model.userTimeline } ! [] + Mastodon.StatusResult result -> + case result of + Ok status -> + { model | userTimeline = status :: model.userTimeline } ! [] - Err error -> - { model | errors = error :: model.errors } ! [] + Err error -> + { model | errors = (logError "StatusResult" error message) :: model.errors } ! [] NewWebsocketLocalMessage message -> -- @TODO