From fab471c137be9ed5df8eb2bfd39efd0f6a973cac Mon Sep 17 00:00:00 2001 From: Kirill Date: Fri, 17 Jan 2025 15:06:48 +0400 Subject: [PATCH] Replace err == ... with errors.Is(err, ...) (#129) --- internal/db/last_processed_height.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/internal/db/last_processed_height.go b/internal/db/last_processed_height.go index 82bd5ed..15035d3 100644 --- a/internal/db/last_processed_height.go +++ b/internal/db/last_processed_height.go @@ -3,6 +3,7 @@ package db import ( "context" + "errors" "github.com/babylonlabs-io/babylon-staking-indexer/internal/db/model" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" @@ -13,11 +14,11 @@ func (db *Database) GetLastProcessedBbnHeight(ctx context.Context) (uint64, erro var result model.LastProcessedHeight err := db.collection(model.LastProcessedHeightCollection). FindOne(ctx, bson.M{}).Decode(&result) - if err == mongo.ErrNoDocuments { - // If no document exists, return 0 - return 0, nil - } if err != nil { + if errors.Is(err, mongo.ErrNoDocuments) { + // If no document exists, return 0 + return 0, nil + } return 0, err } return result.Height, nil