From aa0c246f6426e3931ac323f35c11a91188d60cc0 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 29 Jun 2017 20:43:39 +0200 Subject: [PATCH] tmerror now dumps stack trace on %+v as well --- errors/main.go | 13 +++++++++++++ stack/signature.go | 6 ------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/errors/main.go b/errors/main.go index 07239b600a..a4cb8a483c 100644 --- a/errors/main.go +++ b/errors/main.go @@ -5,6 +5,8 @@ package errors **/ import ( + "fmt" + "github.com/pkg/errors" abci "github.com/tendermint/abci/types" @@ -37,6 +39,17 @@ func (t tmerror) Message() string { return t.msg } +// Format handles "%+v" to expose the full stack trace +// concept from pkg/errors +func (t tmerror) Format(s fmt.State, verb rune) { + // special case also show all info + if verb == 'v' && s.Flag('+') { + fmt.Fprintf(s, "%+v\n", t.stackTracer) + } + // always print the normal error + fmt.Fprintf(s, "(%d) %s\n", t.code, t.msg) +} + // Result converts any error into a abci.Result, preserving as much info // as possible if it was already a TMError func Result(err error) abci.Result { diff --git a/stack/signature.go b/stack/signature.go index ca2402394b..13846e516a 100644 --- a/stack/signature.go +++ b/stack/signature.go @@ -1,8 +1,6 @@ package stack import ( - "fmt" - crypto "github.com/tendermint/go-crypto" "github.com/tendermint/basecoin" @@ -53,9 +51,7 @@ func (h Signatures) DeliverTx(ctx basecoin.Context, store types.KVStore, tx base func addSigners(ctx basecoin.Context, sigs []crypto.PubKey) basecoin.Context { perms := make([]basecoin.Actor, len(sigs)) - fmt.Printf("Add %d signers\n", len(sigs)) for i, s := range sigs { - fmt.Printf("Add %X\n", s.Address()) perms[i] = SigPerm(s.Address()) } // add the signers to the context and continue @@ -63,10 +59,8 @@ func addSigners(ctx basecoin.Context, sigs []crypto.PubKey) basecoin.Context { } func getSigners(tx basecoin.Tx) ([]crypto.PubKey, basecoin.Tx, error) { - fmt.Println("getSigners") stx, ok := tx.Unwrap().(Signed) if !ok { - fmt.Printf("Not okay: %#v\n", tx) return nil, basecoin.Tx{}, errors.Unauthorized() } sig, err := stx.Signers()