sourcegraph/internal/database/errors.go
Quinn Slack f6fe8df922
add database.NotFoundError helper type (#63671)
Use it in the 1 place it seemed obvious. I have other changes where it
will be used in more places. This helps standardize our codebase.

## Test plan

CI
2024-07-05 14:26:19 +00:00

20 lines
527 B
Go

package database
// resourceNotFoundError is an error that indicates that a database resource was not found. It can be
// returned by methods that get a single resource (such as Get or GetByXyz).
//
// errcode.IsNotFound(err) == true for notFoundError values.
type resourceNotFoundError struct {
noun string
}
func (e resourceNotFoundError) Error() string {
const notFound = "not found"
if e.noun == "" {
return notFound
}
return e.noun + " " + notFound
}
func (resourceNotFoundError) NotFound() bool { return true }