File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
internal-packages/emails/src Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -127,14 +127,21 @@ export class EmailClient {
127127
128128 async #sendEmail( { to, subject, react } : { to : string ; subject : string ; react : ReactElement } ) {
129129 if ( this . #client) {
130- await this . #client. emails . send ( {
130+ const result = await this . #client. emails . send ( {
131131 from : this . #from,
132132 to,
133133 reply_to : this . #replyTo,
134134 subject,
135135 react,
136136 } ) ;
137137
138+ if ( result . error ) {
139+ console . error (
140+ `Failed to send email to ${ to } , ${ subject } . Error ${ result . error . name } : ${ result . error . message } `
141+ ) ;
142+ throw new EmailError ( result . error ) ;
143+ }
144+
138145 return ;
139146 }
140147
@@ -147,3 +154,11 @@ ${render(react, {
147154 ` ) ;
148155 }
149156}
157+
158+ //EmailError type where you can set the name and message
159+ export class EmailError extends Error {
160+ constructor ( { name, message } : { name : string ; message : string } ) {
161+ super ( message ) ;
162+ this . name = name ;
163+ }
164+ }
You can’t perform that action at this time.
0 commit comments