Warn on shutdown failure only if connected to irc

master
Tyler Sommer 2022-03-05 18:32:49 -07:00
parent f46393ee5b
commit 54a998ca29
Signed by: tyler-sommer
GPG Key ID: C09C010500DBD008
2 changed files with 6 additions and 2 deletions

View File

@ -14,6 +14,8 @@ import (
"code.dopame.me/veonik/squircy3/event"
)
var ErrNotConnected = errors.New("not connected")
type Config struct {
Nick string `toml:"nick"`
Username string `toml:"user"`
@ -225,7 +227,7 @@ func (m *Manager) Disconnect() error {
conn := m.conn
m.mu.RUnlock()
if conn == nil {
return errors.New("not connected")
return ErrNotConnected
}
return conn.Quit()
}

View File

@ -66,7 +66,9 @@ func (p *ircPlugin) HandleShutdown() {
return
}
if err := p.manager.Disconnect(); err != nil {
logrus.Warnln("irc: failed to disconnect before shutting down:", err)
if err != ErrNotConnected {
logrus.Warnln("irc: failed to disconnect before shutting down:", err)
}
}
}