mirror of https://github.com/go-gorm/gorm.git
Add IsRecordNotFoundError method
This commit is contained in:
parent
0cc4d47ce5
commit
c54d23473c
|
@ -24,11 +24,11 @@ The fantastic ORM library for Golang, aims to be developer friendly.
|
|||
|
||||
## Getting Started
|
||||
|
||||
* GORM Guides [jinzhu.github.com/gorm](http://jinzhu.github.io/gorm)
|
||||
* GORM Guides [jinzhu.github.com/gorm](https://jinzhu.github.io/gorm)
|
||||
|
||||
## Upgrading To V1.0
|
||||
|
||||
* [CHANGELOG](http://jinzhu.github.io/gorm/changelog.html)
|
||||
* [CHANGELOG](https://jinzhu.github.io/gorm/changelog.html)
|
||||
|
||||
## Supporting the project
|
||||
|
||||
|
|
12
errors.go
12
errors.go
|
@ -21,6 +21,18 @@ var (
|
|||
// Errors contains all happened errors
|
||||
type Errors []error
|
||||
|
||||
// IsRecordNotFoundError returns current error has record not found error or not
|
||||
func IsRecordNotFoundError(err error) bool {
|
||||
if errs, ok := err.(Errors); ok {
|
||||
for _, err := range errs {
|
||||
if err == ErrRecordNotFound {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return err == ErrRecordNotFound
|
||||
}
|
||||
|
||||
// GetErrors gets all happened errors
|
||||
func (errs Errors) GetErrors() []error {
|
||||
return errs
|
||||
|
|
Loading…
Reference in New Issue