From 8c11205ee61d14abcaca5f55a76d9dc4b2eb161c Mon Sep 17 00:00:00 2001 From: delthas Date: Sat, 4 Apr 2020 04:51:48 +0200 Subject: [PATCH] Send the last error for disconnected networks in network status This adds support for sending the exact error message of a network when it is disconnected, in the reply to the service command `network status`. This lets users easily examine why a network is currently disconnected. No lock is needed because all reads and writes of network.lastError are made in the user goroutine. Closes: https://todo.sr.ht/~emersion/soju/28 --- service.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/service.go b/service.go index 1157239..8fb48cb 100644 --- a/service.go +++ b/service.go @@ -208,6 +208,9 @@ func handleServiceNetworkStatus(dc *downstreamConn, params []string) error { details = fmt.Sprintf("%v channels", len(uc.channels)) } else { statuses = append(statuses, "disconnected") + if net.lastError != nil { + details = net.lastError.Error() + } } if net == dc.network {