Documentation
¶
Index ¶
- Variables
- type Code
- func (c *Code) Code() int
- func (c *Code) Err() error
- func (c *Code) Format(s fmt.State, verb rune)
- func (c *Code) Message() string
- func (c *Code) String() string
- func (c *Code) WithCode(code int) *Code
- func (c *Code) WithMessage(message string) *Code
- func (c *Code) WithMessagef(format string, a ...any) *Code
- type Error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( OK = NewCode(0, "ok") Canceled = NewCode(1, "canceled") Unknown = NewCode(2, "unknown") InvalidArgument = NewCode(3, "invalid argument") DeadlineExceeded = NewCode(4, "deadline exceeded") NotFound = NewCode(5, "not found") InternalError = NewCode(6, "internal error") IllegalInvoke = NewCode(8, "illegal invoke") IllegalRequest = NewCode(9, "illegal request") TooManyRequests = NewCode(10, "too many requests") )
Functions ¶
This section is empty.
Types ¶
type Code ¶
type Code struct {
// contains filtered or unexported fields
}
func Convert ¶
Convert converts err to a code. It returns OK when err is nil, the carried code when err exposes one, and Unknown when err cannot be parsed.
func (*Code) Format ¶
Format implements fmt.Formatter.
The %s verb prints the error code and the error message, and %v prints the error code, the error message and the error detail.
func (*Code) WithMessage ¶ added in v2.1.0
WithMessage returns a copy of c with the message replaced.
Click to show internal directories.
Click to hide internal directories.