fix: enhance error message for mailbox creation failure

This commit is contained in:
Linus Rath
2026-04-22 00:00:01 +02:00
parent 40982bc37b
commit 1810a474a2
+7 -1
View File
@@ -1316,7 +1316,13 @@ export class JMAPClient implements IJMAPClient {
const result = response.methodResponses?.[0]?.[1];
if (result?.notCreated?.[createId]) {
throw new Error(`Failed to create mailbox: ${result.notCreated[createId].type || 'unknown error'}`);
const err = result.notCreated[createId];
const details = [err.type || 'unknown error'];
if (Array.isArray(err.properties) && err.properties.length > 0) {
details.push(`properties=[${err.properties.join(', ')}]`);
}
if (err.description) details.push(err.description);
throw new Error(`Failed to create mailbox: ${details.join(' — ')}`);
}
const created = result?.created?.[createId];