Ajoute le detail des erreurs Postal
This commit is contained in:
Vendored
+10
-2
@@ -26,9 +26,17 @@ function createPostalClient(options) {
|
||||
html_body: input.htmlBody
|
||||
})
|
||||
});
|
||||
const payload = await response.json().catch(() => null);
|
||||
const rawBody = await response.text().catch(() => "");
|
||||
const payload = rawBody.length > 0 ? (() => {
|
||||
try {
|
||||
return JSON.parse(rawBody);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
})() ?? null : null;
|
||||
if (!response.ok || payload?.status !== "success") {
|
||||
throw new Error(`postal_send_failed:${response.status}`);
|
||||
const details = payload?.error?.trim() || payload?.message?.trim() || rawBody.trim().slice(0, 500) || "no_response_body";
|
||||
throw new Error(`postal_send_failed:${response.status}:${details}`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user