on master help sign in
Pull failure handling out of hook
1ff1d11Fang
src/lib/useMailer.js+2−6
@@ -43,14 +43,10 @@ export default function useMailer(emails) {
43 const _sendMail = useCallback(async (email, ticket, rawTx) => {
43 const _sendMail = useCallback(async (email, ticket, rawTx) => {
44 if (STUB_MAILER) {
44 if (STUB_MAILER) {
45 console.log(`${email} - ${ticket}`);
45 console.log(`${email} - ${ticket}`);
46− return;
46+ return true;
47 }
47 }
48
48
49− const mailSuccess = await sendMail(email, ticket, rawTx);
49+ return await sendMail(email, ticket, rawTx);
50−
51− if (!mailSuccess) {
52− throw new Error(`Internal mailing error when mailing ${email}`);
53− }
54 }, []);
50 }, []);
55
51
56 return { ...hasReceivedCache, sendMail: _sendMail };
52 return { ...hasReceivedCache, sendMail: _sendMail };
src/views/Invite/InviteEmail.js+6−1
@@ -318,7 +318,12 @@ export default function InviteEmail() {
318 }
318 }
319
319
320 try {
320 try {
321+ const success = await sendMail(
322+ invite.email,
321− await sendMail(invite.email, invite.ticket, invite.rawTx);
323+ invite.ticket,
324+ invite.rawTx
325+ );
326+ if (!success) throw new Error('Failed to send mail');
322 } catch (error) {
327 } catch (error) {
323 console.error(error);
328 console.error(error);
324 errorCount++;
329 errorCount++;