From 53793aa19097bee8a54af5ad21b42c947abdc1ae Mon Sep 17 00:00:00 2001 From: Greg V Date: Sat, 2 Dec 2023 17:26:51 -0700 Subject: [PATCH] typecheck for #59 --- app/routes/_auth+/signup/index.tsx | 6 +++++- app/utils/email.server.ts | 9 +++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/routes/_auth+/signup/index.tsx b/app/routes/_auth+/signup/index.tsx index 5c841d8..4270428 100644 --- a/app/routes/_auth+/signup/index.tsx +++ b/app/routes/_auth+/signup/index.tsx @@ -118,7 +118,11 @@ export async function action({ request }: DataFunctionArgs) { if (response.status === 'success') { return redirect(redirectTo.pathname + redirectTo.search) } else { - submission.error[''] = response.error.message + submission.error[''] = 'There was an error sending the email.' + response.error; + if ( response.error?.message ){ + submission.error[''] += ' ' + response.error.message; + } + return json( { status: 'error', diff --git a/app/utils/email.server.ts b/app/utils/email.server.ts index 7fbce0b..44172a1 100644 --- a/app/utils/email.server.ts +++ b/app/utils/email.server.ts @@ -64,11 +64,16 @@ export async function sendEmail({ data: response, } as const - } catch (e) { + // Catch full exception + } catch (e : any) { console.error('🔴 error sending email:', JSON.stringify(email)) return { status: 'error', - error: e + error: { + message: e.message || 'Unknown error', + code: e.code || 'Unknown code', + response: e.response || 'Unknown response', + } } } }