Skip to content

Commit

Permalink
[Slack] Stop silencing errors in makeContentFragment() (#2446)
Browse files Browse the repository at this point in the history
  • Loading branch information
lasryaric authored Nov 8, 2023
1 parent 7a07794 commit 1110431
Showing 1 changed file with 12 additions and 30 deletions.
42 changes: 12 additions & 30 deletions connectors/src/connectors/slack/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -702,36 +702,18 @@ async function makeContentFragment(
}
url = permalinkRes.permalink;
}
try {
const channel = await slackClient.conversations.info({
channel: channelId,
});

if (channel.error) {
return new Err(new Error(channel.error));
}
const channel = await slackClient.conversations.info({
channel: channelId,
});

return new Ok({
title: `Thread content from #${channel.channel?.name}`,
content: text,
url: url,
contentType: "slack_thread_content",
} as PostContentFragmentRequestBody);
} catch (e) {
logger.error(
{
error: e,
},
`Unhandled error in makeContentFragment`
);
const slackError = e as CodedError;
if (slackError.code === ErrorCode.PlatformError) {
const platformError = slackError as WebAPIPlatformError;
if (platformError.data.error === "missing_scope") {
return new Ok(null);
}
throw e;
}
return new Ok(null);
if (channel.error) {
return new Err(new Error(channel.error));
}

return new Ok({
title: `Thread content from #${channel.channel?.name}`,
content: text,
url: url,
contentType: "slack_thread_content",
} as PostContentFragmentRequestBody);
}

0 comments on commit 1110431

Please sign in to comment.