Skip to content

Commit

Permalink
fix err handling
Browse files Browse the repository at this point in the history
  • Loading branch information
vadiminshakov committed Dec 18, 2023
1 parent 46fd8e7 commit 4902161
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions core/coordinator/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ func (c *coordinatorImpl) Broadcast(ctx context.Context, req dto.BroadcastReques
// commit
log.Infof("commit %s", req.Key)
if err := c.commit(ctx); err != nil {
s, ok := status.FromError(err)
if !ok {
return &dto.BroadcastResponse{Type: dto.ResponseTypeNack}, fmt.Errorf("failed to extract grpc status code from err: %s", err)
}
if s.Code() == codes.AlreadyExists {
return &dto.BroadcastResponse{Type: dto.ResponseTypeNack}, nil
}
return &dto.BroadcastResponse{Type: dto.ResponseTypeNack}, errors.Wrap(err, "failed to send commit")
}

Expand Down

0 comments on commit 4902161

Please sign in to comment.