diff --git a/.changelog/4067.feature.md b/.changelog/4067.feature.md new file mode 100644 index 00000000000..5b7bfe31d1c --- /dev/null +++ b/.changelog/4067.feature.md @@ -0,0 +1 @@ +Expose runtime query error details to clients diff --git a/go/common/errors/errors.go b/go/common/errors/errors.go index c35e5840682..e74a1e734ac 100644 --- a/go/common/errors/errors.go +++ b/go/common/errors/errors.go @@ -109,7 +109,11 @@ func New(module string, code uint32, msg string) error { func FromCode(module string, code uint32, context string) error { err, exists := registeredErrors.Load(errorKey(module, code)) if !exists || err == errUnknownError { - return errors.New(context) + return WithContext(&codedError{ + module: module, + code: code, + msg: context, + }, context) } return WithContext(err.(*codedError), context) diff --git a/go/common/errors/errors_test.go b/go/common/errors/errors_test.go index 8725abdcecd..fa48a89e243 100644 --- a/go/common/errors/errors_test.go +++ b/go/common/errors/errors_test.go @@ -1,7 +1,6 @@ package errors import ( - "errors" "fmt" "testing" @@ -72,7 +71,7 @@ func TestErrors(t *testing.T) { // Unknown module and code. err = FromCode("test/does-not-exist", 5, "") - require.Equal(err, errors.New("")) - err = FromCode("test/errors", 3, "") - require.Equal(err, errors.New("")) + require.Equal(err, New("test/does-not-exist", 5, "")) + err = FromCode("test/errors", 3, "a test error occurred") + require.Equal(err, WithContext(New("test/errors", 3, "a test error occurred"), "a test error occurred")) }