Skip to content

Commit

Permalink
Use typed error
Browse files Browse the repository at this point in the history
  • Loading branch information
Scandiravian committed Nov 3, 2021
1 parent c0f7ac6 commit 776cc2d
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions e2e/topic.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,13 @@ func (s *Service) validateManagementTopic(ctx context.Context) error {
return fmt.Errorf("validateManagementTopic cannot get metadata of e2e topic: %w", err)
}

// Error code 3 is UnknownTopicOrPartition, meaning that the topic does not exist.
// UnknownTopicOrPartition (Error code 3) means that the topic does not exist.
// If the topic exists, but there's an error, then this should result in a fail
// When the topic doesn't exist, continue to create it
err_code := meta.Topics[0].ErrorCode
topicExists := err_code != 3
err = kerr.TypedErrorForCode(meta.Topics[0].ErrorCode)
topicExists := err != kerr.UnknownTopicOrPartition

if err_code != 0 && topicExists {
err := kerr.ErrorForCode(err_code)
if err != nil && topicExists {
return fmt.Errorf("failed to get metadata for end-to-end topic: %w", err)
}

Expand Down

0 comments on commit 776cc2d

Please sign in to comment.