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.

37 lines
1.5 KiB

  1. package types
  2. var (
  3. code2string = map[CodeType]string{
  4. CodeType_InternalError: "Internal error",
  5. CodeType_EncodingError: "Encoding error",
  6. CodeType_BadNonce: "Error bad nonce",
  7. CodeType_Unauthorized: "Unauthorized",
  8. CodeType_InsufficientFunds: "Insufficient funds",
  9. CodeType_UnknownRequest: "Unknown request",
  10. CodeType_BaseDuplicateAddress: "Error (base) duplicate address",
  11. CodeType_BaseEncodingError: "Error (base) encoding error",
  12. CodeType_BaseInsufficientFees: "Error (base) insufficient fees",
  13. CodeType_BaseInsufficientFunds: "Error (base) insufficient funds",
  14. CodeType_BaseInsufficientGasPrice: "Error (base) insufficient gas price",
  15. CodeType_BaseInvalidInput: "Error (base) invalid input",
  16. CodeType_BaseInvalidOutput: "Error (base) invalid output",
  17. CodeType_BaseInvalidPubKey: "Error (base) invalid pubkey",
  18. CodeType_BaseInvalidSequence: "Error (base) invalid sequence",
  19. CodeType_BaseInvalidSignature: "Error (base) invalid signature",
  20. CodeType_BaseUnknownAddress: "Error (base) unknown address",
  21. CodeType_BaseUnknownPlugin: "Error (base) unknown plugin",
  22. CodeType_BaseUnknownPubKey: "Error (base) unknown pubkey",
  23. }
  24. )
  25. func (c CodeType) IsOK() bool { return c == CodeType_OK }
  26. // HumanCode transforms code into a more humane format, such as "Internal error" instead of 0.
  27. func HumanCode(code CodeType) string {
  28. s, ok := code2string[code]
  29. if !ok {
  30. return "Unknown code"
  31. }
  32. return s
  33. }