include optional data field in error object

```
data
A Primitive or Structured value that contains additional information about the error.
This may be omitted.
The value of this member is defined by the Server (e.g. detailed error information, nested errors etc.).
```
This commit is contained in:
Anton Kaliaev
2017-05-26 17:45:09 +02:00
committed by Ethan Buchman
parent 6c1572c9b8
commit f74de4cb86
4 changed files with 42 additions and 34 deletions

View File

@ -12,6 +12,7 @@ import (
"time"
"github.com/pkg/errors"
types "github.com/tendermint/tendermint/rpc/lib/types"
"github.com/tendermint/tmlibs/log"
)
@ -99,7 +100,7 @@ func RecoverAndLogHandler(handler http.Handler, logger log.Logger) http.Handler
// For the rest,
logger.Error("Panic in RPC HTTP handler", "err", e, "stack", string(debug.Stack()))
rww.WriteHeader(http.StatusInternalServerError)
WriteRPCResponseHTTP(rww, types.RPCInternalError(""))
WriteRPCResponseHTTP(rww, types.RPCInternalError("", e.(error)))
}
}