gorm/errors.go

35 lines
693 B
Go
Raw Normal View History

2013-11-15 14:36:39 +04:00
package gorm
2015-08-13 11:42:13 +03:00
import (
"errors"
"strings"
)
2013-11-15 14:36:39 +04:00
var (
2015-02-17 03:34:01 +03:00
RecordNotFound = errors.New("record not found")
InvalidSql = errors.New("invalid sql")
NoNewAttrs = errors.New("no new attributes")
NoValidTransaction = errors.New("no valid transaction")
CantStartTransaction = errors.New("can't start transaction")
2013-11-15 14:36:39 +04:00
)
2015-08-13 11:42:13 +03:00
type Errors struct {
errors []error
}
2015-08-14 07:29:53 +03:00
func (errs Errors) GetErrors() []error {
2015-08-13 11:42:13 +03:00
return errs.errors
}
func (errs *Errors) Add(err error) {
errs.errors = append(errs.errors, err)
}
func (errs Errors) Error() string {
var errors = []string{}
for _, e := range errs.errors {
errors = append(errors, e.Error())
}
return strings.Join(errors, "; ")
}