Change formatting, stringify errors before returning over JSONRPC

This commit is contained in:
Ingar Shu 2020-08-11 16:49:11 -07:00
parent 02b0c8dd94
commit 8f56814ffb
No known key found for this signature in database
GPG Key ID: BE3D9CE79F22E769
4 changed files with 13 additions and 10 deletions

View File

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

View File

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

View File

@ -34,5 +34,5 @@ type RetrievalEvent struct {
Status retrievalmarket.DealStatus
BytesReceived uint64
FundsSpent abi.TokenAmount
Err error
Err string
}

View File

@ -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 == "" {