fix: modify error handling of incompleteBookingWriteToRecord (#18998)

* fix: modify error handling of incompleteBookingWriteToRecord

* fix: TS error?

* fix: TS error attempt #2?
This commit is contained in:
Alex van Andel
2025-01-29 17:12:33 +00:00
committed by GitHub
parent 1e610ea684
commit b6a7a8f75a
@@ -1302,7 +1302,9 @@ export default class SalesforceCRMService implements CRM {
}
if (!personRecord) {
throw new Error(`No contact or lead found for email ${email}`);
this.log.info(`No contact or lead found for email ${email}`);
// No salesforce entity to update, skip and report success (unrecoverable)
return;
}
// Ensure the fields exist on the record
const existingFields = await this.ensureFieldsExistOnObject(
@@ -1322,7 +1324,12 @@ export default class SalesforceCRMService implements CRM {
...writeOnRecordBody,
})
.catch((e) => {
this.log.error(`Error updating person record for contactId ${personRecord?.Id}`, e);
const contactId = personRecord?.Id || "unknown";
// catch the error and throw a new one with a more descriptive message
const errorMessage = `Error updating person record for contactId '${contactId}': ${
e instanceof Error ? e.message : String(e)
}`;
throw new Error(errorMessage);
});
}
}