From 920347f85d101461d19338f4b1147af76f1151a6 Mon Sep 17 00:00:00 2001 From: Gregory Rudolph Date: Fri, 9 Jul 2021 22:49:46 -0400 Subject: [PATCH] Cleanup conditions for handleError() --- commands.go | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/commands.go b/commands.go index 0aa0156..47b4276 100644 --- a/commands.go +++ b/commands.go @@ -385,17 +385,13 @@ func handleError(err error, m chat1.MsgSummary, msg string) { log.LogError("%+v: %+v", tracker, err) if strings.HasPrefix(err.Error(), "405") { k.SendMessageByConvID(m.ConvID, "Tesla returned an error. Please ensure your vehicle isn't currently being serviced.") - return - } - if strings.HasPrefix(err.Error(), "408") && !m.Content.Attachment.Uploaded { - k.SendMessageByConvID(m.ConvID, "Unable to wake vehicle within the timeframe. Trying to run the command again.") - m.Content.Attachment.Uploaded = true - handleChat(m) - return - } - if strings.HasPrefix(err.Error(), "400") { + } else if strings.HasPrefix(err.Error(), "400") { k.SendMessageByConvID(m.ConvID, "Tesla returned an error. The command you tried to use may need an update. Please contact @rudi9719 with tracking ID %+v and the bad command.", tracker) - return + } else if !m.Content.Attachment.Uploaded && strings.HasPrefix(err.Error(), "408") { + k.SendMessageByConvID(m.ConvID, "Unable to wake vehicle within the timeframe. Trying to run the command again.") + m.Content.Attachment.Uploaded = true + handleChat(m) + } else { + k.SendMessageByConvID(m.ConvID, msg, tracker) } - k.SendMessageByConvID(m.ConvID, msg, tracker) }