storj/internal/errs2/ignore.go
Egon Elbre 615bfca135 Fix TestGetSignee flakiness (#2350)
* add IsCanceled

* fixes to error handling

* fix imports

* retrigger jenkins
2019-06-26 09:30:37 -06:00

30 lines
597 B
Go

// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
package errs2
import (
"context"
"net/http"
"github.com/zeebo/errs"
"google.golang.org/grpc"
)
// IsCanceled returns true, when the error is a cancellation.
func IsCanceled(err error) bool {
return errs.IsFunc(err, func(err error) bool {
return err == context.Canceled ||
err == grpc.ErrServerStopped ||
err == http.ErrServerClosed
})
}
// IgnoreCanceled returns nil, when the operation was about canceling.
func IgnoreCanceled(err error) error {
if IsCanceled(err) {
return nil
}
return err
}