Fix format specifier, limit embed field length to 256 chars

This commit is contained in:
2024-06-09 22:31:47 -05:00
parent b964bfc565
commit b6f43c9c8f
2 changed files with 9 additions and 6 deletions

10
api.go
View File

@@ -304,7 +304,7 @@ func RegisterVehicle(formParams map[string]string, propertyId uint, residentProf
// Sanity check that a proper result was returned // Sanity check that a proper result was returned
if !result.success && !strings.Contains(htmlString, "Denied") { 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 // 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) req := BuildRequestWithBody("GET", "/register-vehicle-confirmation-process", params, nil)
SetTypicalHeaders(req, nil, nil, false) SetTypicalHeaders(req, nil, nil, false)
res, _ := doRequest(req) res, err := doRequest(req)
if res.StatusCode != 200 { 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) 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 true, nil
} }
return false, fmt.Errorf("unexpected response: %s", htmlString) return false, fmt.Errorf("unexpected response: %v - %s", res, htmlString)
} }

View File

@@ -186,8 +186,9 @@ func HandleError(session *discordgo.Session, interaction *discordgo.InteractionC
} }
innerErrorFields = append(innerErrorFields, &discordgo.MessageEmbedField{ innerErrorFields = append(innerErrorFields, &discordgo.MessageEmbedField{
Name: "Error", Name: "Error",
Value: innerError.Error(), // limit to 256 characters
Value: innerError.Error()[:256],
}) })
innerCount += 1 innerCount += 1