diff --git a/examples/counter-with-retry/main.go b/examples/counter-with-retry/main.go index cbab4ed..5076c9c 100644 --- a/examples/counter-with-retry/main.go +++ b/examples/counter-with-retry/main.go @@ -42,7 +42,11 @@ func main() { for i := 1; i < 4; i++ { // Execute function if err = t.Try(fn(i)); err != nil { - panic(err) + if e, ok := err.(trier.TTLError); ok { + fmt.Printf("Number of retries with counter #%v exceeded, retry after %v\n", i, e.TTL()) + } else { + panic(err) + } } } // Output: diff --git a/go.mod b/go.mod index a53dbda..09e1012 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.12 require ( github.com/da440dil/go-ticker v0.0.0 - github.com/da440dil/go-trier v0.0.1 + github.com/da440dil/go-trier v0.0.2 github.com/go-redis/redis v6.15.2+incompatible github.com/golang/protobuf v1.3.2 // indirect github.com/kr/pretty v0.1.0 // indirect diff --git a/go.sum b/go.sum index d051584..4d2c6ee 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ github.com/da440dil/go-ticker v0.0.0 h1:sH/YeYf//tylK2fShGZi2IQRdtFd/YQgiCnOY2CnTNQ= github.com/da440dil/go-ticker v0.0.0/go.mod h1:Ia+nQQeharuhnq/NYri4BrU0kVlU/nsmhHY8+65O3lE= -github.com/da440dil/go-trier v0.0.1 h1:plGC/S++x1ZlNjqI+uv8t/32P3TrNY6ddd57cIaxHdU= -github.com/da440dil/go-trier v0.0.1/go.mod h1:Xc70OohXdJvxPLfUDjJG3TeOiitY7K4jx+Q0tm5dIy0= +github.com/da440dil/go-trier v0.0.2 h1:9NLmR83u9IKIy2/xszUyzL4u82Z/83fZZxggY8jTcF4= +github.com/da440dil/go-trier v0.0.2/go.mod h1:Xc70OohXdJvxPLfUDjJG3TeOiitY7K4jx+Q0tm5dIy0= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=