forked from mirror/gorm
Handle DB error in callbacks
This commit is contained in:
parent
281c5d10f6
commit
3ca4a72a4c
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