rpc: detalize submit* RPC validation error

These changes do not break the compatibility with the C# node response.

It is useful for the end-user to be aware of the failed validation reason.
Also, the `cause` will be displayed at the running node log.
This commit is contained in:
Anna Shaleva 2021-02-25 12:08:41 +03:00
parent 492a89eb02
commit 2fbbadeb56
2 changed files with 12 additions and 6 deletions

View file

@ -93,3 +93,9 @@ func NewSubmitError(code int64, message string) *Error {
func (e *Error) Error() string {
return fmt.Sprintf("%s (%d) - %s - %s", e.Message, e.Code, e.Data, e.Cause)
}
// WrapErrorWithData returns copy of the given error with specified data and cause.
// It does not modify the source error.
func WrapErrorWithData(e *Error, data error) *Error {
return NewError(e.Code, e.HTTPCode, e.Message, data.Error(), data)
}