From b6f43c9c8f9e2e75916f61e43a3487e8273abd6f Mon Sep 17 00:00:00 2001 From: Xevion Date: Sun, 9 Jun 2024 22:31:47 -0500 Subject: [PATCH] Fix format specifier, limit embed field length to 256 chars --- api.go | 10 ++++++---- helpers.go | 5 +++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/api.go b/api.go index dd16f1e..a2331a5 100644 --- a/api.go +++ b/api.go @@ -304,7 +304,7 @@ func RegisterVehicle(formParams map[string]string, propertyId uint, residentProf // Sanity check that a proper result was returned if !result.success && !strings.Contains(htmlString, "Denied") { - return nil, fmt.Errorf("unexpected response: %s", htmlString) + return nil, fmt.Errorf("unexpected response: %v - %s", res, htmlString) } // Parse the HTML response @@ -387,8 +387,10 @@ func RegisterEmailConfirmation(email string, vehicleId string, propertyId string req := BuildRequestWithBody("GET", "/register-vehicle-confirmation-process", params, nil) SetTypicalHeaders(req, nil, nil, false) - res, _ := doRequest(req) - if res.StatusCode != 200 { + res, err := doRequest(req) + if err != nil { + return false, fmt.Errorf("failed to send email confirmation request: %w", err) + } else if res.StatusCode != 200 { return false, fmt.Errorf("unexpected status code: %d", res.StatusCode) } @@ -399,5 +401,5 @@ func RegisterEmailConfirmation(email string, vehicleId string, propertyId string return true, nil } - return false, fmt.Errorf("unexpected response: %s", htmlString) + return false, fmt.Errorf("unexpected response: %v - %s", res, htmlString) } diff --git a/helpers.go b/helpers.go index e8a3cdf..f531dd8 100644 --- a/helpers.go +++ b/helpers.go @@ -186,8 +186,9 @@ func HandleError(session *discordgo.Session, interaction *discordgo.InteractionC } innerErrorFields = append(innerErrorFields, &discordgo.MessageEmbedField{ - Name: "Error", - Value: innerError.Error(), + Name: "Error", + // limit to 256 characters + Value: innerError.Error()[:256], }) innerCount += 1