Change formatting, stringify errors before returning over JSONRPC
This commit is contained in:
parent
02b0c8dd94
commit
8f56814ffb
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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")
|
||||
|
@ -34,5 +34,5 @@ type RetrievalEvent struct {
|
||||
Status retrievalmarket.DealStatus
|
||||
BytesReceived uint64
|
||||
FundsSpent abi.TokenAmount
|
||||
Err error
|
||||
Err string
|
||||
}
|
||||
|
@ -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 == "" {
|
||||
|
Loading…
Reference in New Issue
Block a user