Skip to content

Commit

Permalink
fix: error management
Browse files Browse the repository at this point in the history
  • Loading branch information
kianaza committed Jul 10, 2024
1 parent a02bb71 commit ef0ec11
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions internal/natsclient/jetstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (j *Jetstream) UpdateOrCreateStream() {
} else if err == nats.ErrStreamNotFound && j.config.NewStreamAllow {
j.createStream(j.config.Streams[i])

Check warning on line 92 in internal/natsclient/jetstream.go

View check run for this annotation

Codecov / codecov/patch

internal/natsclient/jetstream.go#L92

Added line #L92 was not covered by tests
} else {
j.logger.Panic("could not add subject", zap.Error(err))
j.logger.Error("could not add subject", zap.String("stream", stream.Name), zap.Error(err))

Check warning on line 94 in internal/natsclient/jetstream.go

View check run for this annotation

Codecov / codecov/patch

internal/natsclient/jetstream.go#L94

Added line #L94 was not covered by tests
}
}
}
Expand All @@ -104,7 +104,7 @@ func (j *Jetstream) updateStream(stream Stream, info *nats.StreamInfo) {
Subjects: subjects,
})
if err != nil {
j.logger.Panic("could not add subject to existing stream", zap.Error(err))
j.logger.Error("could not add subject to existing stream", zap.String("stream", stream.Name), zap.Error(err))

Check warning on line 107 in internal/natsclient/jetstream.go

View check run for this annotation

Codecov / codecov/patch

internal/natsclient/jetstream.go#L107

Added line #L107 was not covered by tests
}
j.logger.Info("stream updated")
}
Expand All @@ -115,12 +115,15 @@ func (j *Jetstream) createStream(stream Stream) {
Subjects: []string{stream.Subject},
})
if err != nil {
j.logger.Panic("could not add stream", zap.Error(err))
j.logger.Error("could not add stream", zap.String("stream", stream.Name), zap.Error(err))

Check warning on line 118 in internal/natsclient/jetstream.go

View check run for this annotation

Codecov / codecov/patch

internal/natsclient/jetstream.go#L118

Added line #L118 was not covered by tests
}
j.logger.Info("add new stream")
}

func (j *Jetstream) StartBlackboxTest() {
if j.config.Streams == nil {
j.logger.Panic("at least one stream is required.")

Check warning on line 125 in internal/natsclient/jetstream.go

View check run for this annotation

Codecov / codecov/patch

internal/natsclient/jetstream.go#L124-L125

Added lines #L124 - L125 were not covered by tests
}
for _, stream := range j.config.Streams {
messageChannel := j.createSubscribe(stream.Subject)
go j.jetstreamPublish(stream.Subject, stream.Name)
Expand Down

0 comments on commit ef0ec11

Please sign in to comment.