-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
feat(datastore): Return Get, GetMulti, Put and PutMulti errors with enhanced details #7061
Conversation
Signed-off-by: Sagar Vakkala <sagarwakawaka@gmail.com>
Signed-off-by: Sagar Vakkala <sagarwakawaka@gmail.com>
Signed-off-by: Sagar Vakkala <sagarwakawaka@gmail.com>
Signed-off-by: Sagar Vakkala <sagarwakawaka@gmail.com>
Signed-off-by: Sagar Vakkala <sagarwakawaka@gmail.com>
Signed-off-by: Sagar Vakkala <sagarwakawaka@gmail.com>
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.
Please revert the unnecessary replacements of errors.New()
and I'll take another look. Thank you!
datastore/datastore.go
Outdated
@@ -114,7 +113,7 @@ func NewClient(ctx context.Context, projectID string, opts ...option.ClientOptio | |||
} | |||
|
|||
if projectID == "" { | |||
return nil, errors.New("datastore: missing project/dataset id") | |||
return nil, fmt.Errorf("datastore: missing project/dataset id") |
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.
In places where no error is being wrapped, you don't need to replace errors.New()
.
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.
@telpirion Thank you for the review. I replaced it for consistency, But I've reverted it now. Please take a look!
datastore/datastore.go
Outdated
@@ -134,19 +133,21 @@ func detectProjectID(ctx context.Context, opts ...option.ClientOption) (string, | |||
return "", fmt.Errorf("fetching creds: %w", err) | |||
} | |||
if creds.ProjectID == "" { | |||
return "", errors.New("datastore: see the docs on DetectProjectID") | |||
return "", fmt.Errorf("datastore: see the docs on DetectProjectID") |
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.
Same as previous.
datastore/datastore.go
Outdated
} | ||
return creds.ProjectID, nil | ||
} | ||
|
||
var ( | ||
// ErrInvalidEntityType is returned when functions like Get or Next are | ||
// passed a dst or src argument of invalid type. | ||
ErrInvalidEntityType = errors.New("datastore: invalid entity type") | ||
ErrInvalidEntityType = fmt.Errorf("datastore: invalid entity type") |
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.
Same as previous.
datastore/datastore.go
Outdated
// ErrInvalidKey is returned when an invalid key is presented. | ||
ErrInvalidKey = errors.New("datastore: invalid key") | ||
ErrInvalidKey = fmt.Errorf("datastore: invalid key") |
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.
Same as previous.
datastore/datastore.go
Outdated
// ErrNoSuchEntity is returned when no entity was found for a given key. | ||
ErrNoSuchEntity = errors.New("datastore: no such entity") | ||
ErrNoSuchEntity = fmt.Errorf("datastore: no such entity") |
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.
Same as previous.
datastore/datastore.go
Outdated
ErrNoSuchEntity = errors.New("datastore: no such entity") | ||
ErrNoSuchEntity = fmt.Errorf("datastore: no such entity") | ||
// ErrDifferentKeyAndDstLength is returned when the length of dst and key are different. | ||
ErrDifferentKeyAndDstLength = fmt.Errorf("datastore: keys and dst slices have different length") |
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.
Same as previous.
Signed-off-by: Sagar Vakkala <sagarwakawaka@gmail.com>
@telpirion The comments have been resolved, Could you check this PR again? |
Closes: #7060
Changes
checkMultiArgs()
logic has been folded inGet()
andPut()
.errors.New
tofmt.Errorf