From d859ee6fe8b3b6fd28463d77b9f69ba435a6f9a3 Mon Sep 17 00:00:00 2001 From: Gregory Rudolph Date: Fri, 9 Jul 2021 22:33:51 -0400 Subject: [PATCH] Update error handler for 405, 408 and 400 --- commands.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/commands.go b/commands.go index d69f34a..72fd529 100644 --- a/commands.go +++ b/commands.go @@ -382,6 +382,19 @@ func openTrunk(m chat1.MsgSummary) { } func handleError(err error, m chat1.MsgSummary, msg string) { tracker := uuid.NewString() - k.SendMessageByConvID(m.ConvID, msg, tracker) 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") { + k.SendMessageByConvID(m.ConvID, "Unable to wake vehicle within the timeframe. Trying to run the command again.") + handleChat(m) + return + } + 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 + } + k.SendMessageByConvID(m.ConvID, msg, tracker) } \ No newline at end of file