Skip to content

Commit 29cae83

Browse files
fix: add extra info to the emailIdentityIds error (#662)
1 parent 9704898 commit 29cae83

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

apps/mail-bridge/queue/mail-processor.ts

+11-4
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ async function resolveOrgAndMailserver({
6666
}
6767
});
6868
if (!rootEmailIdentity)
69-
throw new Error(`No email identity found for root email`);
69+
throw new Error(`No email identity found for root email: ${rcpt_to}`);
7070
return {
7171
orgId: rootEmailIdentity.orgId,
7272
orgPublicId: rootEmailIdentity.org.publicId,
@@ -119,7 +119,12 @@ async function resolveOrgAndMailserver({
119119
}
120120
});
121121
if (!mailServer || mailServer.orgId !== orgId)
122-
throw new Error(`Mailserver not found or does not belong to the org`);
122+
throw new Error(
123+
`Mailserver not found or does not belong to the org ${JSON.stringify({
124+
orgId,
125+
mailserverId
126+
})}`
127+
);
123128

124129
return {
125130
orgId: mailServer.orgId,
@@ -493,7 +498,9 @@ export const worker = createWorker<MailProcessorJobData>(
493498
span?.setAttributes({
494499
'message.addressIds': JSON.stringify(messageAddressIds)
495500
});
496-
throw new Error('No email identity ids found');
501+
throw new Error(
502+
`No email identity ids found: ${JSON.stringify(messageAddressIds, null, 2)}`
503+
);
497504
}
498505

499506
// get the routing rule destinations for each of the email addresses, then get the users and contacts within those routing rules
@@ -1014,7 +1021,7 @@ export const worker = createWorker<MailProcessorJobData>(
10141021
});
10151022
} catch (e) {
10161023
span?.recordException(e as Error);
1017-
console.error('Error processing email');
1024+
console.error('Error processing email', e);
10181025
await discord.info(`Mailbridge Queue Error\n${(e as Error).message}`);
10191026
// Throw the error to be caught by the worker, and moving to failed jobs
10201027
throw e;

0 commit comments

Comments
 (0)