Skip to content

Commit

Permalink
Error on stop order not found
Browse files Browse the repository at this point in the history
  • Loading branch information
evsamsonov committed Aug 10, 2024
1 parent daf39b5 commit 92477ac
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions tinkoff.go
Original file line number Diff line number Diff line change
Expand Up @@ -526,19 +526,13 @@ func (t *Tinkoff) cancelStopOrder(ctx context.Context, id string) error {
AccountId: t.accountID,
StopOrderId: id,
}
loggerWithRequest := t.logger.With(zap.Any("cancelStopOrderRequest", cancelStopOrderRequest))
logger := t.logger.With(zap.Any("cancelStopOrderRequest", cancelStopOrderRequest))

_, err := t.stopOrderClient.CancelStopOrder(ctx, cancelStopOrderRequest)
if status.Code(err) == codes.NotFound {
loggerWithRequest.Warn("Stop order is not found", zap.Error(err))
return nil
}
if err != nil {
t.logger.Error("Failed to cancel stop order", zap.Error(err))
if _, err := t.stopOrderClient.CancelStopOrder(ctx, cancelStopOrderRequest); err != nil {
return fmt.Errorf("cancel stop order: %w", err)
}

t.logger.Info("Stop order was canceled", zap.String("id", id))
logger.Info("Stop order was canceled", zap.String("id", id))
return nil
}

Expand Down

0 comments on commit 92477ac

Please sign in to comment.