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 · Fixed by #3133
Closed

spanner: new method for declaring spanner.Error #3122

skdrums opened this issue Nov 2, 2020 · 1 comment · Fixed by #3133
Assignees
Labels
api: spanner Issues related to the Spanner API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@skdrums
Copy link

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.

@skdrums skdrums added the triage me I really want to be triaged. label Nov 2, 2020
@product-auto-label product-auto-label bot added the api: spanner Issues related to the Spanner API. label Nov 2, 2020
@skuruppu skuruppu added priority: p2 Moderately-important priority. Fix may not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. and removed triage me I really want to be triaged. labels Nov 2, 2020
@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 commented Nov 4, 2020

Thank you for dealing with this issue:)

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
Labels
api: spanner Issues related to the Spanner API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants