mirror of
https://github.com/complexcaresolutions/cms.c2sgmbh.git
synced 2026-03-17 23:14:12 +00:00
fix: handle non-JSON responses in test email and prevent cascading failures
- Add content-type check in TestEmailButton before parsing response as JSON - Wrap updateEmailLog in error handler with try-catch to prevent double failures Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
0c222b9aa9
commit
6b4dae8eeb
2 changed files with 18 additions and 4 deletions
|
|
@ -126,6 +126,16 @@ export const TestEmailButton: React.FC = () => {
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const contentType = response.headers.get('content-type') || ''
|
||||||
|
if (!contentType.includes('application/json')) {
|
||||||
|
setResult({
|
||||||
|
success: false,
|
||||||
|
message: `Server-Fehler (HTTP ${response.status}). Bitte Seite neu laden und erneut versuchen.`,
|
||||||
|
})
|
||||||
|
setStatus('error')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const data = await response.json()
|
const data = await response.json()
|
||||||
|
|
||||||
if (response.ok && data.success) {
|
if (response.ok && data.success) {
|
||||||
|
|
|
||||||
|
|
@ -264,10 +264,14 @@ export async function sendTenantEmail(
|
||||||
|
|
||||||
// Log aktualisieren (status: failed)
|
// Log aktualisieren (status: failed)
|
||||||
if (logId) {
|
if (logId) {
|
||||||
await updateEmailLog(payload, logId, {
|
try {
|
||||||
status: 'failed',
|
await updateEmailLog(payload, logId, {
|
||||||
error: errorMessage,
|
status: 'failed',
|
||||||
})
|
error: errorMessage,
|
||||||
|
})
|
||||||
|
} catch (logError) {
|
||||||
|
console.error(`[Email] Failed to update email log ${logId}:`, logError)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.error(`[Email] Error for tenant ${tenantId}:`, error)
|
console.error(`[Email] Error for tenant ${tenantId}:`, error)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue