From 3ca4a72a4c3a189e8cba1d348c0b41070846e7ed Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Mon, 17 Aug 2015 16:38:01 +0800 Subject: [PATCH] Handle DB error in callbacks --- scope.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scope.go b/scope.go index 7b6764a6..fe3fccc3 100644 --- a/scope.go +++ b/scope.go @@ -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)) }