backend/pkg/post/repository/error.go

35 lines
712 B
Go
Raw Normal View History

2025-11-19 09:06:44 +00:00
package repository
import (
"errors"
"backend/pkg/library/cassandra"
)
// Common repository errors
var (
// ErrNotFound is returned when a requested resource is not found
ErrNotFound = errors.New("resource not found")
// ErrInvalidInput is returned when input validation fails
ErrInvalidInput = errors.New("invalid input")
// ErrDuplicateKey is returned when attempting to insert a document with a duplicate key
ErrDuplicateKey = errors.New("duplicate key error")
)
// IsNotFound checks if the error is a not found error
func IsNotFound(err error) bool {
if err == nil {
return false
}
if err == ErrNotFound {
return true
}
if cassandra.IsNotFound(err) {
return true
}
return false
}