ext/result.go in ruby_snowflake_client-1.0.1 vs ext/result.go in ruby_snowflake_client-1.0.2
- old
+ new
@@ -19,18 +19,25 @@
"time"
gopointer "github.com/mattn/go-pointer"
)
+func wrapRbRaise(err error) {
+ fmt.Printf("[ruby-snowflake-client] Error encountered: %s\n", err.Error())
+ fmt.Printf("[ruby-snowflake-client] Will call `rb_raise`\n")
+ rb_raise(C.rb_eArgError, "%s", err.Error())
+}
+
func getResultStruct(self C.VALUE) *SnowflakeResult {
ivar := C.rb_ivar_get(self, RESULT_IDENTIFIER)
str := GetGoStruct(ivar)
ptr := gopointer.Restore(str)
sr, ok := ptr.(*SnowflakeResult)
if !ok || sr.rows == nil {
- rb_raise(C.rb_eArgError, "%s", errors.New("Empty result; please run a query via `client.fetch(\"SQL\")`"))
+ err := errors.New("Empty result; please run a query via `client.fetch(\"SQL\")`")
+ wrapRbRaise(err)
return nil
}
return sr
}
@@ -103,11 +110,12 @@
rawData[i] = &rawResult[i]
}
err := rows.Scan(rawData...)
if err != nil {
- rb_raise(C.rb_eArgError, "Cannot scan row: '%s'", err)
+ err = fmt.Errorf("Cannot scan row: '%s'", err)
+ wrapRbRaise(err)
}
// trick from postgres; keep hash: pg_result.c:1088
hash := C.rb_hash_dup(res.keptHash)
for idx, raw := range rawResult {
@@ -137,10 +145,11 @@
rbVal = C.rb_time_timespec_new(ts, 0)
case string:
str := v
rbVal = RbString(str)
default:
- rb_raise(C.rb_eArgError, "Cannot parse type '%s'", fmt.Errorf("%T", v))
+ err := fmt.Errorf("Cannot parse type : '%T'", v)
+ wrapRbRaise(err)
}
}
C.rb_hash_aset(hash, col_name, rbVal)
}
return hash