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.

31 lines
579 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. )
  14. func (r RetCode) Error() error {
  15. switch r {
  16. case RetCodeOK:
  17. return nil
  18. default:
  19. return errors.New(r.String())
  20. }
  21. }
  22. //go:generate stringer -type=RetCode
  23. // NOTE: The previous comment generates r.String().
  24. // To run it, `go get golang.org/x/tools/cmd/stringer`
  25. // and `go generate` in tmsp/types