Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle exceptions in Slack API #14

Merged
merged 1 commit into from
Dec 8, 2019
Merged

Handle exceptions in Slack API #14

merged 1 commit into from
Dec 8, 2019

Conversation

jkehres
Copy link
Owner

@jkehres jkehres commented Dec 2, 2019

Fixes #11

@jkehres jkehres requested a review from m6jones December 2, 2019 21:46
throw new AppError(`Failed to post message: ${result.error}`, 500);
try {
const result = await slack.chat.postEphemeral({channel, text, blocks, user});
if (!result.ok) {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is possible but just in case. The docs suggest yes but in practice we've seen exceptions on failures.

https://api.slack.com/methods/chat.postEphemeral#response

blocks,
slackId: latestRecord.slackId
});
} catch (err) {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will catch both Slack and DynamoDB failures.

@jkehres jkehres merged commit 5466b13 into master Dec 8, 2019
@jkehres jkehres deleted the slack_error_handling branch December 8, 2019 02:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Catch exceptions thrown by Slack SDK
1 participant