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

Implement MsgCount for Tigris #928

Merged
merged 22 commits into from
Jul 26, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Handle errors through GRPC codes
  • Loading branch information
Elena Grahovac committed Jul 21, 2022
commit 8ab87806767ebbab49c77790692b60b21a98a4f8
17 changes: 3 additions & 14 deletions internal/handlers/tigris/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ package tigris

import (
"context"
"errors"

"github.com/tigrisdata/tigris-client-go/api/client/v1/api"
"github.com/tigrisdata/tigris-client-go/driver"
"go.uber.org/zap"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

"github.com/FerretDB/FerretDB/internal/tjson"
"github.com/FerretDB/FerretDB/internal/types"
Expand All @@ -42,18 +42,7 @@ func (h *Handler) fetch(ctx context.Context, param fetchParam) ([]*types.Documen
collection, err := db.DescribeCollection(ctx, param.collection)

if err != nil {
var tigErr *api.Error

if !errors.As(err, &tigErr) {
return nil, lazyerrors.Error(err)
}

if tigErr.Code == nil {
panic("Tigris error code is nil")
}

switch *tigErr.Code {
case api.NOTFOUND:
if status.Code(err) == codes.NotFound {
rumyantseva marked this conversation as resolved.
Show resolved Hide resolved
h.L.Debug(
"Collection doesn't exist, handling a case to deal with a non-existing collection (return empty list)",
zap.String("db", param.db), zap.String("collection", param.collection),
Expand Down