chore: make error clearer (#1514)

This commit is contained in:
chenquan
2022-02-09 00:40:05 -06:00
committed by GitHub
parent 822ee2e1c5
commit 9c2c90e533
4 changed files with 18 additions and 5 deletions

View File

@@ -7,6 +7,9 @@ import (
"github.com/zeromicro/go-zero/core/lang"
)
// errTimeout indicates a timeout.
var errTimeout = errors.New("timeout")
type (
// Ticker interface wraps the Chan and Stop methods.
Ticker interface {
@@ -70,7 +73,7 @@ func (ft *fakeTicker) Tick() {
func (ft *fakeTicker) Wait(d time.Duration) error {
select {
case <-time.After(d):
return errors.New("timeout")
return errTimeout
case <-ft.done:
return nil
}