From 8f56814ffb5b6b257132f4495c6995a88ae97241 Mon Sep 17 00:00:00 2001 From: Ingar Shu Date: Tue, 11 Aug 2020 16:49:11 -0700 Subject: [PATCH] Change formatting, stringify errors before returning over JSONRPC --- api/test/deals.go | 4 ++-- cli/client.go | 11 +++++------ markets/loggers/loggers.go | 2 +- node/impl/client/client.go | 6 +++++- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/api/test/deals.go b/api/test/deals.go index 5b5f04e41..289445083 100644 --- a/api/test/deals.go +++ b/api/test/deals.go @@ -400,8 +400,8 @@ func testRetrieval(t *testing.T, ctx context.Context, err error, client *impl.Fu } updates, err := client.ClientRetrieve(ctx, offers[0].Order(caddr), ref) for update := range updates { - if update.Err != nil { - t.Fatalf("%+v", err) + if update.Err != "" { + t.Fatalf("%v", err) } } diff --git a/cli/client.go b/cli/client.go index 5c2574364..5bc0f4a0d 100644 --- a/cli/client.go +++ b/cli/client.go @@ -846,12 +846,11 @@ var clientRetrieveCmd = &cli.Command{ for { select { case evt, chOpen := <-updates: - - fmt.Printf("Retrieval Event: %s, State: %s, BytesReceived: %d, PaymentSent: %s\n", + fmt.Printf("> Recv: %s, Paid %s, %s (%s)\n", + types.SizeStr(types.NewInt(evt.BytesReceived)), + types.FIL(evt.FundsSpent), retrievalmarket.ClientEvents[evt.Event], retrievalmarket.DealStatuses[evt.Status], - evt.BytesReceived, - evt.FundsSpent.String(), ) if !chOpen { @@ -859,8 +858,8 @@ var clientRetrieveCmd = &cli.Command{ return nil } - if evt.Err != nil { - return xerrors.Errorf("retrieval failed: %w", err) + if evt.Err != "" { + return xerrors.Errorf("retrieval failed: %v", err) } case <-ctx.Done(): return xerrors.Errorf("retrieval timed out") diff --git a/markets/loggers/loggers.go b/markets/loggers/loggers.go index 58dc6d97d..6f386dbba 100644 --- a/markets/loggers/loggers.go +++ b/markets/loggers/loggers.go @@ -34,5 +34,5 @@ type RetrievalEvent struct { Status retrievalmarket.DealStatus BytesReceived uint64 FundsSpent abi.TokenAmount - Err error + Err string } diff --git a/node/impl/client/client.go b/node/impl/client/client.go index befcae0b1..2823ca263 100644 --- a/node/impl/client/client.go +++ b/node/impl/client/client.go @@ -410,7 +410,11 @@ func (a *API) clientRetrieve(ctx context.Context, order api.RetrievalOrder, ref defer close(events) finish := func(e error) { - events <- marketevents.RetrievalEvent{Err: e} + errStr := "" + if e != nil { + errStr = e.Error() + } + events <- marketevents.RetrievalEvent{Err: errStr} } if order.MinerPeer.ID == "" {