Skip to content

Commit

Permalink
fix: modify error handling of incompleteBookingWriteToRecord (calcom#…
Browse files Browse the repository at this point in the history
…18998)

* fix: modify error handling of incompleteBookingWriteToRecord

* fix: TS error?

* fix: TS error attempt #2?
  • Loading branch information
emrysal authored Jan 29, 2025
1 parent 1e610ea commit b6a7a8f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/app-store/salesforce/lib/CrmService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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);
});
}
}

0 comments on commit b6a7a8f

Please sign in to comment.