Skip to content

Commit c1eaf35

Browse files
committed
Use errors.As() instead of type assertion.
1 parent be17763 commit c1eaf35

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

exporter/replset_config_collector.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ func (d *replSetGetConfigCollector) Collect(ch chan<- prometheus.Metric) {
5050
var m bson.M
5151

5252
if err := res.Decode(&m); err != nil {
53-
if e, ok := err.(mongo.CommandError); ok {
53+
var e *mongo.CommandError;
54+
if errors.As(err, &e) {
5455
if e.Code == replicationNotYetInitialized || e.Code == replicationNotEnabled {
5556
return
5657
}

0 commit comments

Comments
 (0)