Skip to content

Commit

Permalink
Make error reporting verbose
Browse files Browse the repository at this point in the history
Without proper error reporting we can't tell why something failed.
This commit adds wrapping of Redis errors with our error messages.
  • Loading branch information
dzeban committed Apr 22, 2019
1 parent 38273a0 commit 3ea1488
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ require (
github.com/go-redis/redis v6.15.2+incompatible
github.com/onsi/ginkgo v1.8.0 // indirect
github.com/onsi/gomega v1.5.0 // indirect
github.com/pkg/errors v0.8.1
github.com/spf13/pflag v1.0.3
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ github.com/onsi/ginkgo v1.8.0 h1:VkHVNpR4iVnU8XQR6DBm8BqYjN7CRzw+xKUbVVbbW9w=
github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v1.5.0 h1:izbySO9zDPmjJ8rDjLvkA2zJHIo+HkYXHnf7eN7SSyo=
github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd h1:nTDtHvHSdCn1m6ITfMRqtOd/9+7a3s8RBNOZ3eYZzJA=
Expand Down
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ package main

import (
"fmt"
"log"
"os"

"github.com/go-redis/redis"
"github.com/pkg/errors"
"github.com/spf13/pflag"
)

// exec executes pipeline and ignore error by merely printing it
func exec(pipe redis.Pipeliner) {
_, err := pipe.Exec()
if err != nil {
log.Println(err)
errors.Wrap(err, "pipeline exec failed")
}
}

Expand Down Expand Up @@ -64,7 +64,7 @@ func main() {
// Grab the next portion of keys
keys, cursor, err = redisdb.Scan(cursor, pattern, count).Result()
if err != nil {
log.Println(err)
errors.Wrap(err, "scan failed")
break
}

Expand Down

0 comments on commit 3ea1488

Please sign in to comment.