mirror of
https://github.com/xtr-dev/payload-mailing.git
synced 2025-12-10 16:23:23 +00:00
Fix error handling and improve error messages
- Fix inconsistent error handling in sendEmailTask by re-throwing original Error instances - Preserve stack traces and error context instead of creating new Error wrappers - Improve generic error messages in emailProcessor utilities with specific details - Add actionable guidance for common configuration issues - Help developers understand what went wrong and how to fix it - Bump version to 0.4.1
This commit is contained in:
@@ -10,8 +10,19 @@ export async function processEmailById(payload: Payload, emailId: string): Promi
|
||||
// Get mailing context from payload
|
||||
const mailingContext = (payload as any).mailing
|
||||
|
||||
if (!mailingContext || !mailingContext.service) {
|
||||
throw new Error('Mailing plugin not properly initialized')
|
||||
if (!mailingContext) {
|
||||
throw new Error(
|
||||
'Mailing plugin not found on payload instance. ' +
|
||||
'Ensure the mailingPlugin is properly configured in your Payload config plugins array.'
|
||||
)
|
||||
}
|
||||
|
||||
if (!mailingContext.service) {
|
||||
throw new Error(
|
||||
'Mailing service not available. ' +
|
||||
'The plugin may not have completed initialization. ' +
|
||||
'Check that email configuration is properly set up in your Payload config.'
|
||||
)
|
||||
}
|
||||
|
||||
// Process the specific email
|
||||
@@ -27,8 +38,19 @@ export async function processAllEmails(payload: Payload): Promise<void> {
|
||||
// Get mailing context from payload
|
||||
const mailingContext = (payload as any).mailing
|
||||
|
||||
if (!mailingContext || !mailingContext.service) {
|
||||
throw new Error('Mailing plugin not properly initialized')
|
||||
if (!mailingContext) {
|
||||
throw new Error(
|
||||
'Mailing plugin not found on payload instance. ' +
|
||||
'Ensure the mailingPlugin is properly configured in your Payload config plugins array.'
|
||||
)
|
||||
}
|
||||
|
||||
if (!mailingContext.service) {
|
||||
throw new Error(
|
||||
'Mailing service not available. ' +
|
||||
'The plugin may not have completed initialization. ' +
|
||||
'Check that email configuration is properly set up in your Payload config.'
|
||||
)
|
||||
}
|
||||
|
||||
// Process pending emails first
|
||||
|
||||
Reference in New Issue
Block a user