tendermint/types/result.go

74 lines
1.7 KiB
Go
Raw Normal View History

package types
import (
"fmt"
)
2017-11-30 11:29:12 -08:00
const (
CodeTypeOK uint32 = 0
)
2017-12-01 22:48:37 -08:00
// IsOK returns true if Code is OK.
func (r ResponseCheckTx) IsOK() bool {
return r.Code == CodeTypeOK
}
// IsErr returns true if Code is something other than OK.
func (r ResponseCheckTx) IsErr() bool {
2017-11-30 11:29:12 -08:00
return r.Code != CodeTypeOK
}
// Error implements error interface by formatting response as string.
func (r ResponseCheckTx) Error() string {
return fmtError(r.Code, r.Log)
}
2017-12-01 22:48:37 -08:00
// IsOK returns true if Code is OK.
func (r ResponseDeliverTx) IsOK() bool {
return r.Code == CodeTypeOK
}
// IsErr returns true if Code is something other than OK.
func (r ResponseDeliverTx) IsErr() bool {
2017-11-30 11:29:12 -08:00
return r.Code != CodeTypeOK
}
// Error implements error interface by formatting response as string.
func (r ResponseDeliverTx) Error() string {
return fmtError(r.Code, r.Log)
}
2017-12-01 22:48:37 -08:00
// IsOK returns true if Code is OK.
func (r ResponseCommit) IsOK() bool {
return r.Code == CodeTypeOK
}
2017-11-22 15:44:39 -08:00
// IsErr returns true if Code is something other than OK.
func (r ResponseCommit) IsErr() bool {
2017-11-30 11:29:12 -08:00
return r.Code != CodeTypeOK
2017-11-22 15:44:39 -08:00
}
// Error implements error interface by formatting response as string.
func (r ResponseCommit) Error() string {
return fmtError(r.Code, r.Log)
}
2017-12-01 22:48:37 -08:00
// IsOK returns true if Code is OK.
func (r ResponseQuery) IsOK() bool {
return r.Code == CodeTypeOK
}
// IsErr returns true if Code is something other than OK.
func (r ResponseQuery) IsErr() bool {
2017-11-30 11:29:12 -08:00
return r.Code != CodeTypeOK
}
// Error implements error interface by formatting response as string.
func (r ResponseQuery) Error() string {
return fmtError(r.Code, r.Log)
}
func fmtError(code uint32, log string) string {
return fmt.Sprintf("Error code (%d): %s", code, log)
}