Sponsor: improve expire message (#26284)

This commit is contained in:
Michael Geers 2025-12-31 13:25:03 +01:00 • committed by GitHub
parent af9927d421
commit 916de19f4f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 2 deletions

View file

@ -71,6 +71,8 @@ test.describe("sponsor token", () => {
await textarea.fill(EXPIRED_TOKEN);
// Try to save to trigger validation
await modal.getByRole("button", { name: "Save" }).click();
await expect(modal).toContainText("token is expired");
await expect(modal).toContainText(
"token is expired - get a fresh one from https://sponsor.evcc.io"
);
});
});

View file

@ -3,6 +3,7 @@ package sponsor
import (
"context"
"fmt"
"strings"
"sync"
"time"
@ -75,7 +76,11 @@ func ConfigureSponsorship(token string) error {
Subject = unavailable
err = nil
} else {
err = fmt.Errorf("sponsortoken: %w", err)
if strings.Contains(err.Error(), "token is expired") {
err = fmt.Errorf("%w - get a fresh one from https://sponsor.evcc.io", err)
} else {
err = fmt.Errorf("sponsortoken: %w", err)
}
}
}