From 45976a4111eedbfbb8c3cf1e0ca21a27972be03a Mon Sep 17 00:00:00 2001 From: Evgeniy Stratonikov Date: Mon, 27 Sep 2021 15:37:29 +0300 Subject: [PATCH] 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) }