forked from mirror/gorm
Handle DB error in callbacks
This commit is contained in:
parent
dd0d4d931f
commit
018a7e69ec
4
scope.go
4
scope.go
|
@ -213,7 +213,9 @@ func (scope *Scope) CallMethod(name string, checkError bool) {
|
||||||
case func(s *Scope) error:
|
case func(s *Scope) error:
|
||||||
scope.Err(f(scope))
|
scope.Err(f(scope))
|
||||||
case func(s *DB) error:
|
case func(s *DB) error:
|
||||||
scope.Err(f(scope.NewDB()))
|
newDB := scope.NewDB()
|
||||||
|
scope.Err(f(newDB))
|
||||||
|
scope.Err(newDB.Error)
|
||||||
default:
|
default:
|
||||||
scope.Err(fmt.Errorf("unsupported function %v", name))
|
scope.Err(fmt.Errorf("unsupported function %v", name))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue