Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit d37d25e

Browse files
committed
Address error messages
1 parent 11f3608 commit d37d25e

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

api/jsonapi.go

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1622,7 +1622,11 @@ func (i *jsonAPIHandler) POSTOrderConfirmation(w http.ResponseWriter, r *http.Re
16221622
return
16231623
}
16241624

1625-
order, _ := i.node.GetOrder(conf.OrderID)
1625+
order, err := i.node.GetOrder(conf.OrderID)
1626+
if err != nil {
1627+
ErrorResponse(w, http.StatusInternalServerError, err.Error())
1628+
return
1629+
}
16261630
v5contract := order.Contract
16271631

16281632
contract, state, funded, records, _, _, err := i.node.Datastore.Sales().GetByOrderId(conf.OrderID)
@@ -1791,7 +1795,11 @@ func (i *jsonAPIHandler) POSTRefund(w http.ResponseWriter, r *http.Request) {
17911795
}
17921796

17931797
// TODO: Remove once broken contracts are migrated
1794-
order, _ := i.node.GetOrder(can.OrderID)
1798+
order, err := i.node.GetOrder(can.OrderID)
1799+
if err != nil {
1800+
ErrorResponse(w, http.StatusInternalServerError, err.Error())
1801+
return
1802+
}
17951803
v5contract := order.Contract
17961804

17971805
lookupCoin := v5contract.BuyerOrder.Payment.AmountCurrency.Code
@@ -1994,7 +2002,11 @@ func (i *jsonAPIHandler) POSTOrderFulfill(w http.ResponseWriter, r *http.Request
19942002
}
19952003

19962004
// TODO: Remove once broken contracts are migrated
1997-
order, _ := i.node.GetOrder(fulfill.OrderId)
2005+
order, err := i.node.GetOrder(fulfill.OrderId)
2006+
if err != nil {
2007+
ErrorResponse(w, http.StatusNotFound, "order not found")
2008+
return
2009+
}
19982010
v5contract := order.Contract
19992011

20002012
lookupCoin := v5contract.BuyerOrder.Payment.AmountCurrency.Code
@@ -2223,7 +2235,11 @@ func (i *jsonAPIHandler) GETCase(w http.ResponseWriter, r *http.Request) {
22232235
}
22242236

22252237
if buyerContract.BuyerOrder.Payment.BigAmount == "" {
2226-
v5order, _ := repo.ToV5Order(buyerContract.BuyerOrder, nil)
2238+
v5order, err := repo.ToV5Order(buyerContract.BuyerOrder, nil)
2239+
if err != nil {
2240+
ErrorResponse(w, http.StatusInternalServerError, err.Error())
2241+
return
2242+
}
22272243
buyerContract.BuyerOrder = v5order
22282244
}
22292245

@@ -2342,7 +2358,12 @@ func (i *jsonAPIHandler) POSTReleaseEscrow(w http.ResponseWriter, r *http.Reques
23422358
}
23432359

23442360
// TODO: Remove once broken contracts are migrated
2345-
order, _ := i.node.GetOrder(rel.OrderID)
2361+
order, err := i.node.GetOrder(rel.OrderID)
2362+
if err != nil {
2363+
ErrorResponse(w, http.StatusBadRequest, "Could not retrieve the order")
2364+
return
2365+
}
2366+
23462367
lookupCoin := order.Contract.BuyerOrder.Payment.AmountCurrency.Code
23472368
_, err = i.node.LookupCurrency(lookupCoin)
23482369
if err != nil {

core/confirmation.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ func (n *OpenBazaarNode) ConfirmOfflineOrder(oldState pb.OrderState, contract *p
106106
}
107107

108108
order, err := repo.ToV5Order(contract.BuyerOrder, n.LookupCurrency)
109+
if err != nil {
110+
return err
111+
}
112+
109113
wal, err := n.Multiwallet.WalletForCurrencyCode(order.Payment.AmountCurrency.Code)
110114
if err != nil {
111115
return err

0 commit comments

Comments
 (0)