add error prints for standard replies

This commit is contained in:
Shivaram Lingamneni 2021-03-03 01:36:19 -05:00
parent d39993c074
commit dc67fb1e17

@ -215,6 +215,10 @@ func (irc *Connection) setupCallbacks() {
// so they happen before any client-added callbacks
irc.addCallback(RPL_ENDOFMOTD, irc.handleRegistration, true, 0)
irc.addCallback(ERR_NOMOTD, irc.handleRegistration, true, 0)
irc.AddCallback("FAIL", irc.handleStandardReplies)
irc.AddCallback("WARN", irc.handleStandardReplies)
irc.AddCallback("NOTE", irc.handleStandardReplies)
}
func (irc *Connection) handleRplWelcome(e Event) {
@ -390,3 +394,12 @@ func splitCAPToken(token string) (name, value string) {
return token[:equalIdx], token[equalIdx+1:]
}
}
func (irc *Connection) handleStandardReplies(e Event) {
// unconditionally print messages for FAIL and WARN;
// re. NOTE, if debug is enabled, we print the raw line anyway
switch e.Command {
case "FAIL", "WARN":
irc.Log.Printf("Received error code from server: %s %s\n", e.Command, strings.Join(e.Params, " "))
}
}