veza/veza-backend-api/internal/services/errors.go
senke 6111ae6136
Some checks failed
Backend API CI / test-unit (push) Failing after 0s
Backend API CI / test-integration (push) Failing after 0s
Frontend CI / test (push) Failing after 0s
Storybook Audit / Build & audit Storybook (push) Failing after 0s
feat(v0.10.3): Commentaires & Interactions Sociales - F201-F215
- F201: Commentaires avec timestamp cliquable, modération mots-clés
- F202: Likes privés (compteur visible créateur uniquement)
- F203: Reposts de tracks sur le profil, bouton Repost, onglet Reposts
- F204: Notifications (commentaire, repost), pas de gamification

Backend: migrations 127/128, comment_moderation_service, track_repost_service,
  GetTrackLikes/GetTrack masquent like_count pour non-créateurs
Frontend: LikeButton isCreator, RepostButton, Reposts tab profil, timestamp seek
2026-03-09 10:30:47 +01:00

109 lines
4 KiB
Go

package services
import "errors"
// Common service errors
var (
// ErrUserAlreadyExists is returned when trying to create a user that already exists
ErrUserAlreadyExists = errors.New("user already exists")
// ErrInvalidCredentials is returned when login credentials are invalid
ErrInvalidCredentials = errors.New("invalid credentials")
// ErrUserNotFound is returned when a user is not found
ErrUserNotFound = errors.New("user not found")
// ErrInvalidToken is returned when a token is invalid or expired
ErrInvalidToken = errors.New("invalid or expired token")
// ErrWeakPassword is returned when password doesn't meet requirements
ErrWeakPassword = errors.New("password does not meet security requirements")
// ErrInvalidEmail is returned when email format is invalid
ErrInvalidEmail = errors.New("invalid email format")
// ErrPlaylistNotFound is returned when a playlist is not found
ErrPlaylistNotFound = errors.New("playlist not found")
// ErrTrackNotFound is returned when a track is not found
ErrTrackNotFound = errors.New("track not found")
// ErrForbidden is returned when access is denied
ErrForbidden = errors.New("forbidden")
// ErrAccessDenied is alias for ErrForbidden
ErrAccessDenied = ErrForbidden
// ErrTrackAlreadyInPlaylist is returned when adding a duplicate track
ErrTrackAlreadyInPlaylist = errors.New("track already in playlist")
// ErrTitleEmpty is returned when title is empty
ErrTitleEmpty = errors.New("title cannot be empty")
// ErrTitleTooLong is returned when title exceeds limit
ErrTitleTooLong = errors.New("title must be less than 200 characters")
// ErrInvalidTrackID is returned when track ID is invalid/nil
ErrInvalidTrackID = errors.New("invalid track ID")
// ErrInvalidUserID is returned when user ID is invalid/nil
ErrInvalidUserID = errors.New("invalid user ID")
// ErrInvalidBitrate is returned when bitrate is invalid
ErrInvalidBitrate = errors.New("invalid bitrate")
// ErrInvalidBufferLevel is returned when buffer level is invalid
ErrInvalidBufferLevel = errors.New("invalid buffer level")
// ErrCommentNotFound is returned when a comment is not found
ErrCommentNotFound = errors.New("comment not found")
// ErrParentCommentNotFound is returned when a parent comment is not found
ErrParentCommentNotFound = errors.New("parent comment not found")
// ErrParentTrackMismatch is returned when parent comment is on different track
ErrParentTrackMismatch = errors.New("parent comment belongs to a different track")
// ErrModerationRejected is returned when comment content fails keyword moderation (v0.10.3 F201)
ErrModerationRejected = errors.New("content does not comply with moderation rules")
// ErrRoomNotFound is returned when a room/conversation is not found
ErrRoomNotFound = errors.New("conversation not found")
// Cloud storage errors (v0.501 C1)
ErrQuotaExceeded = errors.New("storage quota exceeded")
ErrFileNotFound = errors.New("file not found")
ErrFolderNotFound = errors.New("folder not found")
ErrInvalidMimeType = errors.New("invalid file type")
ErrFileTooLarge = errors.New("file too large")
ErrNotOwner = errors.New("not owner of resource")
)
// IsUserAlreadyExistsError checks if the error is a user already exists error
func IsUserAlreadyExistsError(err error) bool {
return errors.Is(err, ErrUserAlreadyExists)
}
// IsInvalidCredentialsError checks if the error is an invalid credentials error
func IsInvalidCredentialsError(err error) bool {
return errors.Is(err, ErrInvalidCredentials)
}
// IsUserNotFoundError checks if the error is a user not found error
func IsUserNotFoundError(err error) bool {
return errors.Is(err, ErrUserNotFound)
}
// IsInvalidTokenError checks if the error is an invalid token error
func IsInvalidTokenError(err error) bool {
return errors.Is(err, ErrInvalidToken)
}
// IsWeakPassword checks if the error is a weak password error
func IsWeakPassword(err error) bool {
return errors.Is(err, ErrWeakPassword)
}
// IsInvalidEmail checks if the error is an invalid email error
func IsInvalidEmail(err error) bool {
return errors.Is(err, ErrInvalidEmail)
}