2019-04-17 11:09:44 +01:00
|
|
|
// 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"
|
|
|
|
)
|
|
|
|
|
|
|
|
// IgnoreCanceled returns nil, when the operation was about canceling.
|
2019-04-23 12:13:57 +01:00
|
|
|
func IgnoreCanceled(err error) error {
|
2019-06-26 08:38:07 +01:00
|
|
|
if errs.IsFunc(err, func(err error) bool {
|
2019-04-23 12:13:57 +01:00
|
|
|
return err == context.Canceled ||
|
2019-04-17 11:09:44 +01:00
|
|
|
err == grpc.ErrServerStopped ||
|
2019-04-23 12:13:57 +01:00
|
|
|
err == http.ErrServerClosed
|
|
|
|
}) {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return err
|
|
|
|
}
|