Debian Codegraph @

status/status.go

raw symbols SCIP
1 package status
2
3 import (
4 "fmt"
5
6 "github.com/influxdata/yarpc/codes"
7 )
8
9 func (m *Status) Error() string {
10 return fmt.Sprintf("rpc error: code = %s desc = %s", m.Code, m.Message)
11 }
12
13 // FromError returns a Status representing err if it was produced from this
14 // package, otherwise it returns nil, false.
15 func FromError(err error) (s *Status, ok bool) {
16 if err == nil {
17 return &Status{Code: codes.OK}, true
18 }
19 if s, ok := err.(*Status); ok {
20 return s, true
21 }
22 return nil, false
23 }
24
25 // Errorf returns Error(c, fmt.Sprintf(format, a...)).
26 func Errorf(c codes.Code, format string, a ...interface{}) error {
27 return &Status{Code: c, Message: fmt.Sprintf(format, a...)}
28 }