Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spanner: new method for declaring spanner.Error #3122

Closed
skdrums opened this issue Nov 2, 2020 · 1 comment
Closed

spanner: new method for declaring spanner.Error #3122

skdrums opened this issue Nov 2, 2020 · 1 comment

Comments

@skdrums
Copy link

@skdrums skdrums commented Nov 2, 2020

Is your feature request related to a problem? Please describe.
In spanner, Code field in Error struct is deprecated and spanner recommends using ErrCode method for extracting the err code.
But we don't have a method for declaring it(ex. NewError()). we can't declare spanner.Error struct without Error.Code field in unit tests.

Describe the solution you'd like

I want a new method for declaration of spanner.Error struct.
ex. cloud.google.com/go/spanner/errors.go

package spanner

import ...

type Error struct {
. . .
}

// something new below
func NewError(err error) *Error {
 . . .
}

Describe alternatives you've considered

spanner user can declare spanner.Error struct in unit tests without deprecated spanner.Error.Code field.

@skuruppu skuruppu assigned olavloite and unassigned skuruppu Nov 2, 2020
olavloite added a commit that referenced this issue Nov 3, 2020
The ToSpannerError method should be exported to allow users to create
Spanner errors to use with unit tests. Currently, that was only possible
by creating a struct directly and filling the deprecated Code field. That
is however no longer recommended, as the code field might be removed in a
future release.

Fixes #3122
@skdrums
Copy link
Author

@skdrums skdrums commented Nov 4, 2020

Thank you for dealing with this issue:)

Loading

olavloite added a commit that referenced this issue Nov 4, 2020
* feat: export ToSpannerError

The ToSpannerError method should be exported to allow users to create
Spanner errors to use with unit tests. Currently, that was only possible
by creating a struct directly and filling the deprecated Code field. That
is however no longer recommended, as the code field might be removed in a
future release.

Fixes #3122

* fix: use New instead of Newf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

3 participants