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.

53 lines
1.2 KiB

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
  1. package types
  2. import (
  3. "fmt"
  4. )
  5. const (
  6. CodeTypeOK uint32 = 0
  7. )
  8. // IsErr returns true if Code is something other than OK.
  9. func (r ResponseCheckTx) IsErr() bool {
  10. return r.Code != CodeTypeOK
  11. }
  12. // Error implements error interface by formatting response as string.
  13. func (r ResponseCheckTx) Error() string {
  14. return fmtError(r.Code, r.Log)
  15. }
  16. // IsErr returns true if Code is something other than OK.
  17. func (r ResponseDeliverTx) IsErr() bool {
  18. return r.Code != CodeTypeOK
  19. }
  20. // Error implements error interface by formatting response as string.
  21. func (r ResponseDeliverTx) Error() string {
  22. return fmtError(r.Code, r.Log)
  23. }
  24. // IsErr returns true if Code is something other than OK.
  25. func (r ResponseCommit) IsErr() bool {
  26. return r.Code != CodeTypeOK
  27. }
  28. // Error implements error interface by formatting response as string.
  29. func (r ResponseCommit) Error() string {
  30. return fmtError(r.Code, r.Log)
  31. }
  32. // IsErr returns true if Code is something other than OK.
  33. func (r ResponseQuery) IsErr() bool {
  34. return r.Code != CodeTypeOK
  35. }
  36. // Error implements error interface by formatting response as string.
  37. func (r ResponseQuery) Error() string {
  38. return fmtError(r.Code, r.Log)
  39. }
  40. func fmtError(code uint32, log string) string {
  41. return fmt.Sprintf("Error code (%d): %s", code, log)
  42. }