Skip to content

Commit 6efa757

Browse files
committed
Log thrown errors as warnings in conversation cleanup, not just false returns
1 parent 27ad2b8 commit 6efa757

File tree

1 file changed

+14
-5
lines changed
  • hrm-domain/scheduled-tasks/conversation-cleanup

1 file changed

+14
-5
lines changed

hrm-domain/scheduled-tasks/conversation-cleanup/index.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,20 @@ const removeConversationsBySids = async (
9999
}
100100
}
101101
console.debug(`Removing conversation ${sid} from account ${accountSid}`);
102-
const result = await twilioClient.conversations.v1.conversations.get(sid).remove();
103-
if (result) {
104-
console.debug(`Removed conversation ${sid} from account ${accountSid}`);
105-
} else {
106-
console.warn(`Failed to remove conversation ${sid} from account ${accountSid}`);
102+
try {
103+
const result = await twilioClient.conversations.v1.conversations.get(sid).remove();
104+
if (result) {
105+
console.debug(`Removed conversation ${sid} from account ${accountSid}`);
106+
} else {
107+
console.warn(
108+
`Failed to remove conversation ${sid} from account ${accountSid}. Method returned false`,
109+
);
110+
}
111+
} catch (err) {
112+
console.warn(
113+
`Failed to remove conversation ${sid} from account ${accountSid}. Error thrown:`,
114+
err,
115+
);
107116
}
108117
});
109118
return Promise.all(removePromises);

0 commit comments

Comments
 (0)