File tree 1 file changed +16
-1
lines changed
internal-packages/emails/src 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -127,14 +127,21 @@ export class EmailClient {
127
127
128
128
async #sendEmail( { to, subject, react } : { to : string ; subject : string ; react : ReactElement } ) {
129
129
if ( this . #client) {
130
- await this . #client. emails . send ( {
130
+ const result = await this . #client. emails . send ( {
131
131
from : this . #from,
132
132
to,
133
133
reply_to : this . #replyTo,
134
134
subject,
135
135
react,
136
136
} ) ;
137
137
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
+
138
145
return ;
139
146
}
140
147
@@ -147,3 +154,11 @@ ${render(react, {
147
154
` ) ;
148
155
}
149
156
}
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