Handle DB error in callbacks

This commit is contained in:
Jinzhu 2015-08-17 16:38:01 +08:00
parent dd0d4d931f
commit 018a7e69ec
1 changed files with 3 additions and 1 deletions

View File

@ -213,7 +213,9 @@ func (scope *Scope) CallMethod(name string, checkError bool) {
case func(s *Scope) error:
scope.Err(f(scope))
case func(s *DB) error:
scope.Err(f(scope.NewDB()))
newDB := scope.NewDB()
scope.Err(f(newDB))
scope.Err(newDB.Error)
default:
scope.Err(fmt.Errorf("unsupported function %v", name))
}