All checks were successful
gitea-deepak/gogmagog/pipeline/head This commit looks good
30 lines
474 B
Go
30 lines
474 B
Go
package models
|
|
|
|
import (
|
|
"database/sql"
|
|
)
|
|
|
|
type notFoundError struct {
|
|
error
|
|
}
|
|
|
|
func (e *notFoundError) NotFound() bool {
|
|
return true
|
|
}
|
|
|
|
// IsNotFoundError returns true if the model deems it a not found error.
|
|
func IsNotFoundError(err error) bool {
|
|
type notFound interface {
|
|
NotFound() bool
|
|
}
|
|
te, ok := err.(notFound)
|
|
return ok && te.NotFound()
|
|
}
|
|
|
|
func wrapNotFound(err error) error {
|
|
if err == sql.ErrNoRows {
|
|
return ¬FoundError{error: err}
|
|
}
|
|
return err
|
|
}
|