Merge pull request #5293 from filecoin-project/fix/fund-mgr-nice-err
Better error message when withdrawing funds
This commit is contained in:
commit
72871597cd
@ -2,6 +2,7 @@ package market
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
@ -501,7 +502,13 @@ func (a *fundedAddress) processWithdrawals(withdrawals []*fundRequest) (msgCid c
|
|||||||
// request with an error
|
// request with an error
|
||||||
newWithdrawalAmt := types.BigAdd(withdrawalAmt, amt)
|
newWithdrawalAmt := types.BigAdd(withdrawalAmt, amt)
|
||||||
if newWithdrawalAmt.GreaterThan(netAvail) {
|
if newWithdrawalAmt.GreaterThan(netAvail) {
|
||||||
err := xerrors.Errorf("insufficient funds for withdrawal of %d", amt)
|
msg := fmt.Sprintf("insufficient funds for withdrawal of %s: ", types.FIL(amt))
|
||||||
|
msg += fmt.Sprintf("net available (%s) = available (%s) - reserved (%s)",
|
||||||
|
types.FIL(types.BigSub(netAvail, withdrawalAmt)), types.FIL(avail), types.FIL(a.state.AmtReserved))
|
||||||
|
if !withdrawalAmt.IsZero() {
|
||||||
|
msg += fmt.Sprintf(" - queued withdrawals (%s)", types.FIL(withdrawalAmt))
|
||||||
|
}
|
||||||
|
err := xerrors.Errorf(msg)
|
||||||
a.debugf("%s", err)
|
a.debugf("%s", err)
|
||||||
req.Complete(cid.Undef, err)
|
req.Complete(cid.Undef, err)
|
||||||
continue
|
continue
|
||||||
|
Loading…
Reference in New Issue
Block a user