From e6aa9b76ee4f6cb9d28408c57951954705dacda5 Mon Sep 17 00:00:00 2001 From: Evgeniy Stratonikov Date: Mon, 27 Sep 2021 15:33:06 +0300 Subject: [PATCH 1/2] mempool: reword `ErrConflict` message, fix #2197 Make it more user-friendly. Signed-off-by: Evgeniy Stratonikov --- pkg/core/mempool/mem_pool.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/core/mempool/mem_pool.go b/pkg/core/mempool/mem_pool.go index 47a9a8723..7e1bb98ef 100644 --- a/pkg/core/mempool/mem_pool.go +++ b/pkg/core/mempool/mem_pool.go @@ -22,7 +22,7 @@ var ( // ErrConflict is returned when transaction being added is incompatible // with the contents of the memory pool (Sender doesn't have enough GAS // to pay for all transactions in the pool). - ErrConflict = errors.New("conflicts with the memory pool") + ErrConflict = errors.New("conflicts: insufficient funds for all pooled tx") // ErrDup is returned when transaction being added is already present // in the memory pool. ErrDup = errors.New("already in the memory pool") From 45976a4111eedbfbb8c3cf1e0ca21a27972be03a Mon Sep 17 00:00:00 2001 From: Evgeniy Stratonikov Date: Mon, 27 Sep 2021 15:37:29 +0300 Subject: [PATCH 2/2] rpc/response: beautify error message If `Error.Cause` is nil, omit ugly `%s!`. Signed-off-by: Evgeniy Stratonikov --- pkg/rpc/response/errors.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/rpc/response/errors.go b/pkg/rpc/response/errors.go index e19df1166..de0bf4057 100644 --- a/pkg/rpc/response/errors.go +++ b/pkg/rpc/response/errors.go @@ -90,6 +90,9 @@ func NewSubmitError(code int64, message string) *Error { // Error implements the error interface. func (e *Error) Error() string { + if e.Cause == nil { + return fmt.Sprintf("%s (%d) - %s", e.Message, e.Code, e.Data) + } return fmt.Sprintf("%s (%d) - %s - %s", e.Message, e.Code, e.Data, e.Cause) }