commit 439f4e0077a5f1564ab56b3af56691aa72d70ffd
parent 203c7098e62c00922ff8357c60b99ab3e05347a4
Author: brookjeynes <me@brookjeynes.dev>
Date: Wed, 24 Jun 2026 14:14:50 +1000
refactor: fmt.Errorf -> errors.New when not using formatter
Signed-off-by: brookjeynes <me@brookjeynes.dev>
Diffstat:
4 files changed, 29 insertions(+), 29 deletions(-)
diff --git a/internal/server/edit-artist.go b/internal/server/edit-artist.go
@@ -26,17 +26,17 @@ func parseEditArtistForm(form EditArtistForm) (domain.Artist, error) {
// name
if !domain.NoTrailingOrLeadingSpaceRegex.MatchString(form.Name) {
- return artist, fmt.Errorf("Artist name must not be empty or have leading/trailing whitespace")
+ return artist, errors.New("Artist name must not be empty or have leading/trailing whitespace")
}
// latin name
var latinName *string
if form.LatinName != "" {
if !domain.NoTrailingOrLeadingSpaceRegex.MatchString(form.LatinName) {
- return artist, fmt.Errorf("Latin name must not be empty or have leading/trailing whitespace")
+ return artist, errors.New("Latin name must not be empty or have leading/trailing whitespace")
}
if !domain.IsValidSortNameRegex.MatchString(form.LatinName) {
- return artist, fmt.Errorf("Latin name contains invalid characters")
+ return artist, errors.New("Latin name contains invalid characters")
}
latinName = &form.LatinName
}
@@ -44,7 +44,7 @@ func parseEditArtistForm(form EditArtistForm) (domain.Artist, error) {
// bio
var bio *string
if form.Bio != "" && !domain.NoTrailingOrLeadingSpaceRegex.MatchString(form.Bio) {
- return artist, fmt.Errorf("Artist biography must not be empty or have leading/trailing whitespace")
+ return artist, errors.New("Artist biography must not be empty or have leading/trailing whitespace")
}
if form.Bio != "" {
bio = &form.Bio
@@ -53,7 +53,7 @@ func parseEditArtistForm(form EditArtistForm) (domain.Artist, error) {
// disambiguation
var disambiguation *string
if form.Disambiguation != "" && !domain.NoTrailingOrLeadingSpaceRegex.MatchString(form.Disambiguation) {
- return artist, fmt.Errorf("Artist disambiguation must not be empty or have leading/trailing whitespace")
+ return artist, errors.New("Artist disambiguation must not be empty or have leading/trailing whitespace")
}
if form.Disambiguation != "" {
disambiguation = &form.Disambiguation
diff --git a/internal/server/new-artist.go b/internal/server/new-artist.go
@@ -24,17 +24,17 @@ func parseNewArtistForm(form NewArtistForm) (domain.Artist, error) {
// name
if !domain.NoTrailingOrLeadingSpaceRegex.MatchString(form.Name) {
- return artist, fmt.Errorf("Artist name must not be empty or have leading/trailing whitespace")
+ return artist, errors.New("Artist name must not be empty or have leading/trailing whitespace")
}
// latin name
var latinName *string
if form.LatinName != "" {
if !domain.NoTrailingOrLeadingSpaceRegex.MatchString(form.LatinName) {
- return artist, fmt.Errorf("Latin name must not be empty or have leading/trailing whitespace")
+ return artist, errors.New("Latin name must not be empty or have leading/trailing whitespace")
}
if !domain.IsValidSortNameRegex.MatchString(form.LatinName) {
- return artist, fmt.Errorf("Latin name contains invalid characters")
+ return artist, errors.New("Latin name contains invalid characters")
}
latinName = &form.LatinName
}
@@ -42,7 +42,7 @@ func parseNewArtistForm(form NewArtistForm) (domain.Artist, error) {
// bio
var bio *string
if form.Bio != "" && !domain.NoTrailingOrLeadingSpaceRegex.MatchString(form.Bio) {
- return artist, fmt.Errorf("Artist biography must not be empty or have leading/trailing whitespace")
+ return artist, errors.New("Artist biography must not be empty or have leading/trailing whitespace")
}
if form.Bio != "" {
bio = &form.Bio
@@ -51,7 +51,7 @@ func parseNewArtistForm(form NewArtistForm) (domain.Artist, error) {
// disambiguation
var disambiguation *string
if form.Disambiguation != "" && !domain.NoTrailingOrLeadingSpaceRegex.MatchString(form.Disambiguation) {
- return artist, fmt.Errorf("Artist disambiguation must not be empty or have leading/trailing whitespace")
+ return artist, errors.New("Artist disambiguation must not be empty or have leading/trailing whitespace")
}
if form.Disambiguation != "" {
disambiguation = &form.Disambiguation
diff --git a/internal/server/new-release.go b/internal/server/new-release.go
@@ -26,20 +26,20 @@ func parseNewReleaseForm(form NewReleaseForm) (domain.NewRelease, error) {
// type
if form.Type == "" {
- return release, fmt.Errorf("Type must not be empty")
+ return release, errors.New("Type must not be empty")
}
if _, ok := domain.ReleaseTypes[form.Type]; !ok {
- return release, fmt.Errorf("Invalid type selected")
+ return release, errors.New("Invalid type selected")
}
// title
if !domain.NoTrailingOrLeadingSpaceRegex.MatchString(form.Title) {
- return release, fmt.Errorf("Title name must not be empty or have leading/trailing whitespace")
+ return release, errors.New("Title name must not be empty or have leading/trailing whitespace")
}
// artists
if len(form.ArtistID) == 0 {
- return release, fmt.Errorf("At least one artist is required")
+ return release, errors.New("At least one artist is required")
}
artists := make([]domain.NewReleaseArtist, 0, len(form.ArtistID))
@@ -47,10 +47,10 @@ func parseNewReleaseForm(form NewReleaseForm) (domain.NewRelease, error) {
for i, id := range form.ArtistID {
if id < 0 {
- return release, fmt.Errorf("Invalid artist selection")
+ return release, errors.New("Invalid artist selection")
}
if _, exists := seenArtists[int64(id)]; exists {
- return release, fmt.Errorf("An artist cannot be added more than once")
+ return release, errors.New("An artist cannot be added more than once")
}
seenArtists[int64(id)] = struct{}{}
@@ -65,10 +65,10 @@ func parseNewReleaseForm(form NewReleaseForm) (domain.NewRelease, error) {
var latinTitle *string
if form.LatinTitle != "" {
if !domain.NoTrailingOrLeadingSpaceRegex.MatchString(form.LatinTitle) {
- return release, fmt.Errorf("Latin title must not be empty or have leading/trailing whitespace")
+ return release, errors.New("Latin title must not be empty or have leading/trailing whitespace")
}
if !domain.IsValidSortNameRegex.MatchString(form.LatinTitle) {
- return release, fmt.Errorf("Latin title contains invalid characters")
+ return release, errors.New("Latin title contains invalid characters")
}
latinTitle = &form.LatinTitle
}
diff --git a/internal/server/new-song.go b/internal/server/new-song.go
@@ -30,7 +30,7 @@ func parseNewSongForm(form NewSongForm) (domain.NewSong, error) {
// artists
if len(form.ArtistID) == 0 {
- return song, fmt.Errorf("At least one artist is required")
+ return song, errors.New("At least one artist is required")
}
artists := make([]domain.NewSongArtist, 0, len(form.ArtistID)+len(form.FeaturingID))
@@ -38,10 +38,10 @@ func parseNewSongForm(form NewSongForm) (domain.NewSong, error) {
for i, id := range form.ArtistID {
if id < 0 {
- return song, fmt.Errorf("Invalid artist selection")
+ return song, errors.New("Invalid artist selection")
}
if _, exists := seenArtists[int64(id)]; exists {
- return song, fmt.Errorf("An artist cannot be added more than once")
+ return song, errors.New("An artist cannot be added more than once")
}
seenArtists[int64(id)] = struct{}{}
@@ -55,10 +55,10 @@ func parseNewSongForm(form NewSongForm) (domain.NewSong, error) {
// featuring
for i, id := range form.FeaturingID {
if id < 0 {
- return song, fmt.Errorf("Invalid artist selection")
+ return song, errors.New("Invalid artist selection")
}
if _, exists := seenArtists[int64(id)]; exists {
- return song, fmt.Errorf("An artist cannot be added more than once")
+ return song, errors.New("An artist cannot be added more than once")
}
seenArtists[int64(id)] = struct{}{}
@@ -71,24 +71,24 @@ func parseNewSongForm(form NewSongForm) (domain.NewSong, error) {
// title
if !domain.NoTrailingOrLeadingSpaceRegex.MatchString(form.Title) {
- return song, fmt.Errorf("Title must not be empty or have leading/trailing whitespace")
+ return song, errors.New("Title must not be empty or have leading/trailing whitespace")
}
// latin title
var latinTitle *string
if form.LatinTitle != "" {
if !domain.NoTrailingOrLeadingSpaceRegex.MatchString(form.LatinTitle) {
- return song, fmt.Errorf("Latin title must not be empty or have leading/trailing whitespace")
+ return song, errors.New("Latin title must not be empty or have leading/trailing whitespace")
}
if !domain.IsValidSortNameRegex.MatchString(form.LatinTitle) {
- return song, fmt.Errorf("Latin title contains invalid characters")
+ return song, errors.New("Latin title contains invalid characters")
}
latinTitle = &form.LatinTitle
}
// genres
if len(form.Genres) == 0 {
- return song, fmt.Errorf("At least one genre is required")
+ return song, errors.New("At least one genre is required")
}
genres := make([]domain.Genre, 0, len(form.Genres))
for _, g := range form.Genres {
@@ -117,10 +117,10 @@ func parseNewSongForm(form NewSongForm) (domain.NewSong, error) {
seenReleases := make(map[int64]struct{}, len(form.ReleaseID))
for _, id := range form.ReleaseID {
if id < 0 {
- return song, fmt.Errorf("Invalid release selection")
+ return song, errors.New("Invalid release selection")
}
if _, exists := seenReleases[int64(id)]; exists {
- return song, fmt.Errorf("A release cannot be added more than once")
+ return song, errors.New("A release cannot be added more than once")
}
seenReleases[int64(id)] = struct{}{}