Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check err value before calling errors.Is #291

Merged
merged 1 commit into from
Jun 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions checker/redis/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ import (
"context"
"errors"
"fmt"
"github.com/go-redis/redis/v8"
"regexp"
"strings"
"time"

"github.com/go-redis/redis/v8"

"wait4x.dev/v2/checker"
)

Expand Down Expand Up @@ -113,12 +115,12 @@ func (r *Redis) Check(ctx context.Context) error {
keyHasValue := len(splittedKey) == 2

val, err := client.Get(ctx, splittedKey[0]).Result()
if errors.Is(err, redis.Nil) {
// Redis key does not exist.
return checker.NewExpectedError("the key doesn't exist", nil, "key", splittedKey[0])
}

if err != nil {
if errors.Is(err, redis.Nil) {
// Redis key does not exist.
return checker.NewExpectedError("the key doesn't exist", nil, "key", splittedKey[0])
}

// Error occurred on get Redis key
return err
}
Expand Down
Loading