Skip to content

Commit

Permalink
fix: handle http status 501 when fetch topics from a powered off clus…
Browse files Browse the repository at this point in the history
…ter (#26)
  • Loading branch information
theurichde authored Nov 7, 2022
1 parent d988a9c commit c778ad3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion internal/pkg/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ func (c AivenClient) GetAccountTeamMembersList(accountId string, teamId string)

func (c AivenClient) GetKafkaTopicsList(projectName string, serviceName string) []*aiven.KafkaListTopic {
topics, err := c.client.KafkaTopics.List(projectName, serviceName)
handle(err)
if aivenError, ok := err.(aiven.Error); ok {
if aivenError.Status == 501 {
// Aiven returns 501 if a Kafka Cluster is powered off
return nil
}
handle(err)
}
return topics
}

Expand Down

0 comments on commit c778ad3

Please sign in to comment.