File tree Expand file tree Collapse file tree
packages/polymath-offchain/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -227,38 +227,34 @@ export const applyHandler = async (ctx: Context) => {
227227 otherDetails,
228228 } ;
229229
230- try {
231- const { name : userName , email : userEmail } = user ;
232- if (
233- DEPLOYMENT_STAGE === 'production' &&
234- NETWORKS [ networkId ] . name === 'mainnet'
235- ) {
236- // Send emails to all selected providers
237- const providers = await Provider . find ( { id : { $in : ids } } ) ;
238- for ( let provider of providers ) {
239- const { name : providerName , email : providerEmail } = provider ;
240- await sendProviderApplicationEmail (
241- providerEmail ,
242- providerName ,
243- userName ,
244- userEmail ,
245- application ,
246- false
247- ) ;
248- }
249- } else {
250- // Send dummy email to the issuer instead of the provider
230+ const { name : userName , email : userEmail } = user ;
231+ if (
232+ DEPLOYMENT_STAGE === 'production' &&
233+ NETWORKS [ networkId ] . name === 'mainnet'
234+ ) {
235+ // Send emails to all selected providers
236+ const providers = await Provider . find ( { id : { $in : ids } } ) ;
237+ for ( let provider of providers ) {
238+ const { name : providerName , email : providerEmail } = provider ;
251239 await sendProviderApplicationEmail (
252- userEmail ,
253- userName ,
240+ providerEmail ,
241+ providerName ,
254242 userName ,
255243 userEmail ,
256244 application ,
257- true
245+ false
258246 ) ;
259247 }
260- } catch ( error ) {
261- console . error ( 'Sendgrid error:' , error , error . response . body . errors ) ;
248+ } else {
249+ // Send dummy email to the issuer instead of the provider
250+ await sendProviderApplicationEmail (
251+ userEmail ,
252+ userName ,
253+ userName ,
254+ userEmail ,
255+ application ,
256+ true
257+ ) ;
262258 }
263259
264260 ctx . body = {
Original file line number Diff line number Diff line change @@ -49,7 +49,13 @@ export const sendEmail = async (
4949 html : body ,
5050 } ;
5151 if ( SENDGRID_API_KEY ) {
52- await sgMail . send ( msg ) ;
52+ try {
53+ await sgMail . send ( msg ) ;
54+ } catch ( error ) {
55+ logger . error ( 'SendGrid error:' , error . response . body . errors ) ;
56+ // Still throw the error in order to send it to Sentry.
57+ throw error ;
58+ }
5359 } else {
5460 logger . warn ( 'Not sending email since SENDGRID_API_KEY is not set.' ) ;
5561 logger . warn ( JSON . stringify ( msg ) ) ;
You can’t perform that action at this time.
0 commit comments