Skip to content

Commit

Permalink
fixed error handling approach in checkout service
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitchsplunk committed Mar 26, 2024
1 parent de846fe commit 191a7f0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/checkoutservice/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"go.opentelemetry.io/otel/attribute"
semconv "go.opentelemetry.io/otel/semconv/v1.24.0"
"go.opentelemetry.io/otel/trace"
otelcodes "go.opentelemetry.io/otel/codes"

"github.com/IBM/sarama"
"github.com/google/uuid"
Expand Down Expand Up @@ -332,7 +333,7 @@ type orderPrep struct {
func (cs *checkoutService) prepareOrderItemsAndShippingQuoteFromCart(ctx context.Context, userID, userCurrency string, address *pb.Address) (orderPrep, error) {

ctx, span := tracer.Start(ctx, "prepareOrderItemsAndShippingQuoteFromCart")
defer span.End()
defer span.End()

var out orderPrep
cartItems, err := cs.getUserCart(ctx, userID)
Expand All @@ -341,6 +342,9 @@ func (cs *checkoutService) prepareOrderItemsAndShippingQuoteFromCart(ctx context
}
orderItems, err := cs.prepOrderItems(ctx, cartItems, userCurrency)
if err != nil {
msg := fmt.Sprintf("Error: ProductCatalogService Fail Feature Flag Enabled")
span.SetStatus(otelcodes.Error, msg)
span.AddEvent(msg)
return out, fmt.Errorf("failed to prepare order: %+v", err)
}
shippingUSD, err := cs.quoteShipping(ctx, address, cartItems)
Expand Down

0 comments on commit 191a7f0

Please sign in to comment.