Replace Result.ToQuery with Error.QueryResult (closes #765)
This commit is contained in:
@@ -3,6 +3,8 @@ package types
|
||||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
|
||||
abci "github.com/tendermint/abci/types"
|
||||
)
|
||||
|
||||
// ABCI Response Code
|
||||
@@ -121,6 +123,7 @@ type Error interface {
|
||||
TraceCause(cause error, msg string) Error
|
||||
Cause() error
|
||||
Result() Result
|
||||
QueryResult() abci.ResponseQuery
|
||||
}
|
||||
|
||||
func NewError(code CodeType, msg string) Error {
|
||||
@@ -220,3 +223,11 @@ func (err *sdkError) Result() Result {
|
||||
Log: err.ABCILog(),
|
||||
}
|
||||
}
|
||||
|
||||
// QueryResult allows us to return sdk.Error.QueryResult() in query responses
|
||||
func (err *sdkError) QueryResult() abci.ResponseQuery {
|
||||
return abci.ResponseQuery{
|
||||
Code: uint32(err.ABCICode()),
|
||||
Log: err.ABCILog(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,11 +38,3 @@ type Result struct {
|
||||
func (res Result) IsOK() bool {
|
||||
return res.Code.IsOK()
|
||||
}
|
||||
|
||||
// ToQuery allows us to return sdk.Error.Result() in query responses
|
||||
func (res Result) ToQuery() abci.ResponseQuery {
|
||||
return abci.ResponseQuery{
|
||||
Code: uint32(res.Code),
|
||||
Log: res.Log,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user