Files
ocis/ocis-pkg/indexer/errors/errors.go
T

35 lines
806 B
Go
Raw Normal View History

2020-10-01 17:30:55 +02:00
package errors
import (
"fmt"
)
2020-10-07 16:10:44 +02:00
// AlreadyExistsErr implements the Error interface.
2020-10-01 17:30:55 +02:00
type AlreadyExistsErr struct {
TypeName, Key, Value string
}
func (e *AlreadyExistsErr) Error() string {
return fmt.Sprintf("%s with %s=%s does already exist", e.TypeName, e.Key, e.Value)
}
2020-10-07 16:10:44 +02:00
// IsAlreadyExistsErr checks whether an error is of type AlreadyExistsErr.
2020-10-01 17:30:55 +02:00
func IsAlreadyExistsErr(e error) bool {
_, ok := e.(*AlreadyExistsErr)
return ok
}
2020-10-07 16:10:44 +02:00
// NotFoundErr implements the Error interface.
2020-10-01 17:30:55 +02:00
type NotFoundErr struct {
TypeName, Key, Value string
}
func (e *NotFoundErr) Error() string {
return fmt.Sprintf("%s with %s=%s not found", e.TypeName, e.Key, e.Value)
}
2020-10-07 16:10:44 +02:00
// IsNotFoundErr checks whether an error is of type IsNotFoundErr.
2020-10-01 17:30:55 +02:00
func IsNotFoundErr(e error) bool {
_, ok := e.(*NotFoundErr)
return ok
}