aboutsummaryrefslogtreecommitdiffstats
path: root/library/go/yandex/tvm/tvmtool/errors.go
blob: f0b08a9878acbafe4c4cc86f61279c3517866fe9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package tvmtool

import (
	"fmt"

	"a.yandex-team.ru/library/go/yandex/tvm"
)

// Generic TVM errors, before retry any request it check .Retriable field.
type Error = tvm.Error

const (
	// ErrorAuthFail - auth failed, probably you provides invalid auth token
	ErrorAuthFail = tvm.ErrorAuthFail
	// ErrorBadRequest - tvmtool rejected our request, check .Msg for details
	ErrorBadRequest = tvm.ErrorBadRequest
	// ErrorOther - any other TVM-related errors, check .Msg for details
	ErrorOther = tvm.ErrorOther
)

// Ticket validation error
type TicketError = tvm.TicketError

const (
	TicketErrorInvalidScopes = tvm.TicketInvalidScopes
	TicketErrorOther         = tvm.TicketStatusOther
)

type PingCode uint32

const (
	PingCodeDie = iota
	PingCodeWarning
	PingCodeError
	PingCodeOther
)

func (e PingCode) String() string {
	switch e {
	case PingCodeDie:
		return "HttpDie"
	case PingCodeWarning:
		return "Warning"
	case PingCodeError:
		return "Error"
	case PingCodeOther:
		return "Other"
	default:
		return fmt.Sprintf("Unknown%d", e)
	}
}

// Special ping error
type PingError struct {
	Code PingCode
	Err  error
}

func (e *PingError) Error() string {
	return fmt.Sprintf("tvm: %s (code %s)", e.Err.Error(), e.Code)
}