code_string.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. *
  3. * Copyright 2017 gRPC authors.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. *
  17. */
  18. package codes
  19. import "strconv"
  20. func (c Code) String() string {
  21. switch c {
  22. case OK:
  23. return "OK"
  24. case Canceled:
  25. return "Canceled"
  26. case Unknown:
  27. return "Unknown"
  28. case InvalidArgument:
  29. return "InvalidArgument"
  30. case DeadlineExceeded:
  31. return "DeadlineExceeded"
  32. case NotFound:
  33. return "NotFound"
  34. case AlreadyExists:
  35. return "AlreadyExists"
  36. case PermissionDenied:
  37. return "PermissionDenied"
  38. case ResourceExhausted:
  39. return "ResourceExhausted"
  40. case FailedPrecondition:
  41. return "FailedPrecondition"
  42. case Aborted:
  43. return "Aborted"
  44. case OutOfRange:
  45. return "OutOfRange"
  46. case Unimplemented:
  47. return "Unimplemented"
  48. case Internal:
  49. return "Internal"
  50. case Unavailable:
  51. return "Unavailable"
  52. case DataLoss:
  53. return "DataLoss"
  54. case Unauthenticated:
  55. return "Unauthenticated"
  56. default:
  57. return "Code(" + strconv.FormatInt(int64(c), 10) + ")"
  58. }
  59. }