From 2b7c4e5fa6a5d7bce04f6e233c0d714c67a4e2a4 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Tue, 27 Feb 2024 08:15:33 -0800 Subject: [PATCH] fixup! fix: publish 'error' message for failure after upgrade --- packages/smart-wallet/src/offerWatcher.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/smart-wallet/src/offerWatcher.js b/packages/smart-wallet/src/offerWatcher.js index 5ec73b2706f5..8e437097f8ee 100644 --- a/packages/smart-wallet/src/offerWatcher.js +++ b/packages/smart-wallet/src/offerWatcher.js @@ -193,7 +193,12 @@ export const prepareOfferWatcher = baggage => { facets.helper.updateStatus({ result: UNPUBLISHED_RESULT }); } }, - /** @param {Error} err */ + /** + * Called when the offer result promise rejects. The other two watchers + * are waiting for particular values out of Zoe but they settle at the same time + * and don't need their own error handling. + * @param {Error} err + */ handleError(err) { const { facets } = this; facets.helper.updateStatus({ error: err.toString() }); @@ -220,6 +225,7 @@ export const prepareOfferWatcher = baggage => { facets.helper.updateStatus({ payouts: amounts }); }, /** + * If promise disconnected, watch again. Errors are handled by the resultWatcher. * @param {Error | import('@agoric/internal/src/upgrade-api.js').UpgradeDisconnection} reason * @param {UserSeat} seat */ @@ -227,8 +233,6 @@ export const prepareOfferWatcher = baggage => { const { facets } = this; if (isUpgradeDisconnection(reason)) { void watchForPayout(facets, seat); - } else { - facets.helper.handleError(reason); } }, }, @@ -240,6 +244,8 @@ export const prepareOfferWatcher = baggage => { facets.helper.publishResult(result); }, /** + * If promise disconnected, watch again. Or if there's an Error, handle it. + * * @param {Error | import('@agoric/internal/src/upgrade-api.js').UpgradeDisconnection} reason * @param {UserSeat} seat */ @@ -261,6 +267,7 @@ export const prepareOfferWatcher = baggage => { facets.helper.updateStatus({ numWantsSatisfied: numSatisfied }); }, /** + * If promise disconnected, watch again. Errors are handled by the resultWatcher. * @param {Error | import('@agoric/internal/src/upgrade-api.js').UpgradeDisconnection} reason * @param {UserSeat} seat */ @@ -268,8 +275,6 @@ export const prepareOfferWatcher = baggage => { const { facets } = this; if (isUpgradeDisconnection(reason)) { void watchForNumWants(facets, seat); - } else { - facets.helper.handleError(reason); } }, },