From dc67fb1e175fd6947bc7b95e6372d5c6f32b8885 Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Wed, 3 Mar 2021 01:36:19 -0500 Subject: [PATCH] add error prints for standard replies --- ircevent/irc_callback.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ircevent/irc_callback.go b/ircevent/irc_callback.go index b3c9f77..ff4fe48 100644 --- a/ircevent/irc_callback.go +++ b/ircevent/irc_callback.go @@ -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, " ")) + } +}