You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The error is expected, as the consumer exists!
However, one has to do manual string comparison because an error constant is not provided for this case.
(strings.Contains(cinfo.Error.Description, `consumer already exists`) ||
strings.Contains(cinfo.Error.Description, `consumer name already in use`)) {
Expected result:
This is what I wish I could do:
consumerInfo, err := js.AddConsumer(streamName, consumerConfig)
if err == nats.ErrConsumerExists {
// consumer exists - do what is appropriate
}
Actual result:
This is what I'm forced to do (brittle and ugly):
consumerInfo, err := js.AddConsumer(streamName, consumerConfig)
if err != nil && fmt.Sprintf("%s", err) == "consumer name already in use" {
// consumer exists - do what is appropriate
}
The text was updated successfully, but these errors were encountered:
Defect
Make sure that these boxes are checked before submitting your issue -- thank you!
Versions of
nats.go
and thenats-server
if one was involved:nats.go
v1.14.0OS/Container environment:
N/A
Steps or code to reproduce the issue:
Try to add a consumer when a consumer with the same name exists
The error is expected, as the consumer exists!
However, one has to do manual string comparison because an error constant is not provided for this case.
Here's an example from this repo itself:
Expected result:
This is what I wish I could do:
Actual result:
This is what I'm forced to do (brittle and ugly):
The text was updated successfully, but these errors were encountered: