rpc/response: beautify error message

If `Error.Cause` is nil, omit ugly `%s!<nil>`.

Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgeniy Stratonikov 2021-09-27 15:37:29 +03:00
parent e6aa9b76ee
commit 45976a4111

View file

@ -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)
}