ZoneInterface: log decode errors, log received Zone.

This commit is contained in:
Philippe Pittoli 2023-07-10 05:01:08 +02:00
parent fbb34ba0fe
commit 44004ec96e

View File

@ -479,7 +479,15 @@ handleQuery = case _ of
receivedMessage <- H.liftEffect $ DNSManager.deserialize message
case receivedMessage of
-- Cases where we didn't understand the message.
Left _ -> do
Left err -> do
--H.raise $ Log $ SimpleLog $ "[🤖] received a message that couldn't be decoded..., reason: " <> show err
case err of
(DNSManager.JSONERROR jerr) -> do
H.raise $ Log $ SimpleLog $ "[🤖] JSON parsing error: " <> jerr
(DNSManager.UnknownError unerr) ->
H.raise $ Log $ SimpleLog $ "[🤖] Parsing error: DNSManager.UnknownError" <> (show unerr)
(DNSManager.UnknownNumber ) ->
H.raise $ Log $ SimpleLog $ "[🤖] Parsing error: DNSManager.UnknownNumber"
pure Nothing
-- Cases where we understood the message.
@ -529,6 +537,7 @@ handleQuery = case _ of
(DNSManager.MkZone response) -> do
H.raise $ Log $ SimpleLog $ "[🎉] Got the zone!"
H.raise $ Log $ SimpleLog $ "DEBUG: the zone has domain: " <> response.zone.domain
H.raise $ Log $ SimpleLog $ "DEBUG: zone: " <> show_zone response.zone
(DNSManager.MkSuccess _) -> do
H.raise $ Log $ SimpleLog $ "[🎉] Success!"
@ -545,6 +554,15 @@ handleQuery = case _ of
H.modify_ _ { wsUp = true }
pure (Just a)
where
show_zone zone
= "domain: " <> zone.domain <> " | " <> resource_list zone.resources
where
resource_list [] = ""
resource_list arr = case A.uncons arr of
Just { head: x, tail: xs } -> "(" <> x.rrtype <> ": " <> show x.rrid <> ") " <> resource_list xs
Nothing -> ""
-- Rendering
class_title_size :: Array (HH.ClassName)
class_title_size = [HH.ClassName "is-4"]