Skip to content

Commit

Permalink
Use errors.As() instead of type assertion.
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroshi committed Sep 20, 2021
1 parent be17763 commit 54ded8c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion exporter/replset_config_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ func (d *replSetGetConfigCollector) Collect(ch chan<- prometheus.Metric) {
var m bson.M

if err := res.Decode(&m); err != nil {
if e, ok := err.(mongo.CommandError); ok {
var e *mongo.CommandError
if errors.As(err, &e) {
if e.Code == replicationNotYetInitialized || e.Code == replicationNotEnabled {
return
}
Expand Down

0 comments on commit 54ded8c

Please sign in to comment.