Skip to content
Snippets Groups Projects

Resolve "There are two defined errors (ErrNotFound and ErrCouldNotFind) which represent the same issue"

Files
21
@@ -23,17 +23,6 @@ func (e *ErrNil) Error() string {
return fmt.Sprintf("struct cannot be nil")
}
// ErrNotFound implements the Error interface and is called if a specific ID
// of a storable item could not be found.
type ErrNotFound struct {
ID interface{}
Name interface{}
}
func (e *ErrNotFound) Error() string {
return fmt.Sprintf("ID: %v or Name: %v not found", e.ID, e.Name)
}
// ErrAlreadyExists implements the Error interface and is called if a specific ID
// of a storable item already exists.
type ErrAlreadyExists struct {
@@ -193,11 +182,12 @@ func (e ErrCouldNotUpdate) Error() string {
// ErrCouldNotFind implements the Error interface and is called if a
// stored item can not be found.
type ErrCouldNotFind struct {
StoreName string
ID any
Name string
}
func (e ErrCouldNotFind) Error() string {
return fmt.Sprintf("could not find %s", e.StoreName)
return fmt.Sprintf("ID: %v or Name: %v not found", e.ID, e.Name)
}
// ErrCouldNotCreate implements the Error interface and is called if a
Loading