sqlc icon indicating copy to clipboard operation
sqlc copied to clipboard

Allow errors returned by queries to be wrapped with method name information

Open Hades32 opened this issue 3 years ago • 0 comments

What do you want to change?

Free unicorns! And...

Currently, when I use a bunch of query methods (like q.SelectUnicorns()) and then just do the usual if err!=nil { return err }, then I'll have a hard time figuring out which of those caused the SQL error.

Therefore, I typically do

err := q.SelectUnicorns()`
if err!= nil {
  return fmt.Errorf("SelectUnicorns %w", err)
}

It would be nice if there was a feature toggle to enable this wrapping right within the generated code.

What database engines need to be changed?

No response

What programming language backends need to be changed?

Go

Hades32 avatar May 11 '22 16:05 Hades32