35 lines
712 B
Go
35 lines
712 B
Go
|
|
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
|
||
|
|
}
|
||
|
|
|