Debian Codegraph @

api/internal/utils/errtimeout.go

raw
1 // Copyright 2020 The Kubernetes Authors.
2 // SPDX-License-Identifier: Apache-2.0
3
4 package utils
5
6 import (
7 "fmt"
8 "time"
9
10 "sigs.k8s.io/kustomize/kyaml/errors"
11 )
12
13 type errTimeOut struct {
14 duration time.Duration
15 cmd string
16 }
17
18 func NewErrTimeOut(d time.Duration, c string) *errTimeOut {
19 return &errTimeOut{duration: d, cmd: c}
20 }
21
22 func (e *errTimeOut) Error() string {
23 return fmt.Sprintf("hit %s timeout running '%s'", e.duration, e.cmd)
24 }
25
26 func IsErrTimeout(err error) bool {
27 e := &errTimeOut{}
28 return errors.As(err, &e)
29 }