From 3287c621addf6e2374c600ff28b9aa6218d760c1 Mon Sep 17 00:00:00 2001 From: Dirk McCormick Date: Tue, 5 Jan 2021 16:58:12 +0100 Subject: [PATCH] fix: better withdrawal error message --- chain/market/fundmanager.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/chain/market/fundmanager.go b/chain/market/fundmanager.go index 5df7589fa..090506252 100644 --- a/chain/market/fundmanager.go +++ b/chain/market/fundmanager.go @@ -2,6 +2,7 @@ package market import ( "context" + "fmt" "sync" "github.com/filecoin-project/go-address" @@ -501,7 +502,13 @@ func (a *fundedAddress) processWithdrawals(withdrawals []*fundRequest) (msgCid c // request with an error newWithdrawalAmt := types.BigAdd(withdrawalAmt, amt) if newWithdrawalAmt.GreaterThan(netAvail) { - err := xerrors.Errorf("insufficient funds for withdrawal of %d", amt) + msg := fmt.Sprintf("insufficient funds for withdrawal of %d: ", amt) + msg += fmt.Sprintf("net available (%d) = available (%d) - reserved (%d)", + types.BigSub(netAvail, withdrawalAmt), avail, a.state.AmtReserved) + if !withdrawalAmt.IsZero() { + msg += fmt.Sprintf(" - queued withdrawals (%d)", withdrawalAmt) + } + err := xerrors.Errorf(msg) a.debugf("%s", err) req.Complete(cid.Undef, err) continue