You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
616 B

9 years ago
9 years ago
9 years ago
  1. package types
  2. import (
  3. "errors"
  4. )
  5. type RetCode int
  6. // Reserved return codes
  7. const (
  8. RetCodeOK RetCode = 0
  9. RetCodeInternalError RetCode = 1
  10. RetCodeUnauthorized RetCode = 2
  11. RetCodeInsufficientFees RetCode = 3
  12. RetCodeUnknownRequest RetCode = 4
  13. RetCodeEncodingError RetCode = 5
  14. )
  15. func (r RetCode) Error() error {
  16. switch r {
  17. case RetCodeOK:
  18. return nil
  19. default:
  20. return errors.New(r.String())
  21. }
  22. }
  23. //go:generate stringer -type=RetCode
  24. // NOTE: The previous comment generates r.String().
  25. // To run it, `go get golang.org/x/tools/cmd/stringer`
  26. // and `go generate` in tmsp/types