From cc4fcbe5576c16a9d6313f1d2df1367fd0838ac6 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Fri, 27 Dec 2013 11:19:29 +0800 Subject: [PATCH] ignore error `sql: Scan error on column index...` --- private.go | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/private.go b/private.go index 58fcae90..4ab3ef8c 100644 --- a/private.go +++ b/private.go @@ -46,16 +46,23 @@ func (s *DB) fileWithLineNum() string { } func (s *DB) err(err error) error { - if err != nil { - s.Error = err - if s.logMode == 0 { - if err != RecordNotFound { - go fmt.Println(s.fileWithLineNum(), err) - } - } else { - s.warn(err) - } + if err == nil { + return nil } + + if s.logMode == 0 { + if err != RecordNotFound { + go fmt.Println(s.fileWithLineNum(), err) + error_str := err.Error() + if regexp.MustCompile(`^sql: Scan error on column index`).MatchString(error_str) { + return nil + } + } + } else { + s.warn(err) + } + + s.Error = err return err }