This commit is contained in:
Rainesli(李俊) 2020-04-21 20:52:23 +08:00
parent 33ef36532d
commit 8437348fb5
2 changed files with 11 additions and 0 deletions

1
go.mod
View File

@ -9,6 +9,7 @@ require (
github.com/jinzhu/inflection v1.0.0
github.com/jinzhu/now v1.0.1
github.com/lib/pq v1.1.1
github.com/go-errors/errors v1.0.2
github.com/mattn/go-sqlite3 v2.0.1+incompatible
golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd // indirect
google.golang.org/appengine v1.4.0 // indirect

10
main.go
View File

@ -5,6 +5,7 @@ import (
"database/sql"
"errors"
"fmt"
goerr "github.com/go-errors/errors"
"reflect"
"strings"
"sync"
@ -824,6 +825,15 @@ func (s *DB) AddError(err error) error {
// GetErrors get happened errors from the db
func (s *DB) GetErrors() []error {
errs := s.getErrors()
wrapperErrors := []error{}
for _, err := range errs {
wrapperErrors = append(wrapperErrors, goerr.New(err))
}
return wrapperErrors
}
func (s *DB) getErrors() []error {
if errs, ok := s.Error.(Errors); ok {
return errs
} else if s.Error != nil {