Skip to content

Commit

Permalink
Add IsRecordNotFoundError method
Browse files Browse the repository at this point in the history
  • Loading branch information
jinzhu committed Feb 12, 2018
1 parent 0cc4d47 commit c54d234
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 12 additions & 0 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c54d234

Please sign in to comment.