Skip to content

Commit 985f30c

Browse files
committed
Better error handling when adding INCS
1 parent 1df12e2 commit 985f30c

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

app/server.js

+14-5
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ app.options(/category_select-.*/, async ({ options, ack }) => {
130130
});
131131

132132
// Listen for the interaction from the dropdown menu
133-
app.action(/category_select-.*/, async ({ body, ack, say }) => {
133+
app.action(/category_select-.*/, async ({ body, ack, client }) => {
134134
// Acknowledge the action
135135
await ack();
136136
console.log("body", body);
@@ -141,11 +141,20 @@ app.action(/category_select-.*/, async ({ body, ack, say }) => {
141141
const selectedCategory = body.actions[0].selected_option.text.text;
142142
const dropdown_id = body.actions[0].action_id;
143143
try {
144-
addOrUpdateInc(body.user.username, text, selectedCategory, dropdown_id);
145-
await say(`You selected: ${selectedCategory}`);
144+
// Add or update the incident
145+
await addOrUpdateInc(body.user.username, text, selectedCategory, dropdown_id);
146+
await client.chat.postEphemeral({
147+
channel: body.channel.id, // Send it in the same channel
148+
user: body.user.id, // Send it to the user who made the selection
149+
text: `✅ You added the incident succesfully with the following category: ${selectedCategory}. You can change the incidents category by using the dropdown again.`, // Message with checkmark
150+
});
146151
} catch (error) {
147-
say("There was an error adding the incident. Please try again later.");
148-
console.error("Error adding incident:", error);
152+
await client.chat.postEphemeral({
153+
channel: body.channel.id, // Send it in the same channel
154+
user: body.user.id, // Send it to the user who made the selection
155+
text: "❌ There was an error adding the incident. Please try again later.",
156+
});
157+
console.error("Error adding incident:", error);
149158
}
150159

151160
});

0 commit comments

Comments
 (0)