on master help sign in
invites: display errors correctly
5fc55cbFang
src/lib/useInviter.js+13−5
@@ -159,7 +159,7 @@ const useInviter = () => {
159 () => setNeedFunds(undefined)
159 () => setNeedFunds(undefined)
160 );
160 );
161
161
162− let unsentInvites = [];
162+ let inviteErrors = [];
163 let confirmedInvites = [];
163 let confirmedInvites = [];
164 const txAndMailings = signedInvites.map(async invite => {
164 const txAndMailings = signedInvites.map(async invite => {
165 try {
165 try {
@@ -172,8 +172,12 @@ const useInviter = () => {
172 await waitForTransactionConfirm(_web3, txHash);
172 await waitForTransactionConfirm(_web3, txHash);
173 confirmedInvites.push(invite);
173 confirmedInvites.push(invite);
174 } catch (error) {
174 } catch (error) {
175− console.error(error);
175+ console.error('Error sending invite tx:', error);
176− unsentInvites.push(invite);
176+ if (typeof error === 'string') {
177+ inviteErrors.push(error);
178+ } else if (typeof error === 'object' && error.message) {
179+ inviteErrors.push(error.message);
180+ }
177 return;
181 return;
178 }
182 }
179 });
183 });
@@ -183,8 +187,12 @@ const useInviter = () => {
183 setTxStatus(STATUS.SUCCESS);
187 setTxStatus(STATUS.SUCCESS);
184 setInvites(confirmedInvites);
188 setInvites(confirmedInvites);
185
189
186− if (unsentInvites.length > 0) {
190+ if (inviteErrors.length > 0) {
187− return { errors: { [FORM_ERROR]: unsentInvites } };
191+ return {
192+ errors: {
193+ [FORM_ERROR]: ['Error sending invites: ', ...inviteErrors],
194+ },
195+ };
188 }
196 }
189
197
190 if (errorCount > 0) {
198 if (errorCount > 0) {