Replace Result.ToQuery with Error.QueryResult (closes #765)

This commit is contained in:
Christopher Goes
2018-04-03 22:15:52 +02:00
parent 47c97c24d3
commit 0888096677
5 changed files with 17 additions and 14 deletions
+11
View File
@@ -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(),
}
}
-8
View File
@@ -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,
}
}