-
Notifications
You must be signed in to change notification settings - Fork 938
fix returned error values in defer functions #946
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hah. I was going through and creating a PR for this by adding a test file to the original repo. Beat me to the punch.
defer func() { | ||
if derr := recover(); derr != nil { | ||
err = errors.New(fmt.Sprintf("execInternal unexpected error: %+v", derr)) | ||
} | ||
}() | ||
|
||
stmt, err := db.Prepare(query) | ||
var stmt *sql.Stmt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh you do have a spacing issue here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh. I wonder how this passed CI? CI checks diff vs. gofmt
-ed code.
This is copied from openark/orchestrator#946 with a slight tweak to the an indent. Originates from the PR openark/orchestrator#943 that applies to this codebase too. When we define the variable and attempt to set it in a defer function, the value we're returning isn't what we expect. Instead we can name the return values as variables and set that instead.
@zmoazeni please do |
Sorry about the delay; I expect to look into & merge a bunch of community PRs during the first two weeks of October. |
All good @shlomi-noach. I've been super busy on my side too. Haven't done anything in OSS-land lately. |
Fixes #943 (and more scenarios like the one reported).
An
err
was not correctly returned when modified by adefer
function insqlutils.go
.