Skip to content

Commit

Permalink
Merge pull request #194 from stephenyeargin/feature/responder-send-error
Browse files Browse the repository at this point in the history
feature: add sendError to Responder
  • Loading branch information
stephenyeargin authored Dec 12, 2024
2 parents a94617d + a485f16 commit 798aefb
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
4 changes: 4 additions & 0 deletions .devcontainer/.profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# trust the repo
# fixes:
# - fatal: detected dubious ownership in repository at '/workspaces/bot-zero'.
git config --global --add safe.directory "$PWD"
9 changes: 8 additions & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
FROM mcr.microsoft.com/devcontainers/typescript-node:1-20-bullseye

# Install the npm packages globally
RUN npm install -g npm@10.7.0 \
RUN npm install -g npm@10.9.2 \
&& npm install -g npm-check-updates

COPY ./startup.sh /
RUN chmod +x /startup.sh

# Append the profile to the current .bashrc and .zshrc files
# this makes sure we keep the current behavior like colors and aliases
COPY ./.profile /tmp/.profile
RUN cat /tmp/.profile >> /home/node/.bashrc && \
cat /tmp/.profile >> /home/node/.zshrc && \
rm /tmp/.profile
5 changes: 0 additions & 5 deletions .devcontainer/startup.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
#!/bin/sh

# trust the repo
# fixes:
# - fatal: detected dubious ownership in repository at '/workspaces/bot-zero'.
git config --global --add safe.directory "$PWD"

# install NPM packages
echo ""
echo "Installing packages..."
Expand Down
2 changes: 1 addition & 1 deletion src/Bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class Bot {
*/
sendError(message, context) {
context.robot.logger.error(message);
context.send(message);
this.adapter.responder.sendError(context, message);
}

/**
Expand Down
9 changes: 9 additions & 0 deletions src/adapters/Responder.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ class Responder {
send(res, title, image, link) {
res.send(`${title}: ${image} - ${link}`);
}

/**
* Sends the error message to Hubot.
* @param {Hubot.Response} res the context.
* @param {string} message the error message.
*/
sendError(res, message) {
res.send(message);
}
}

exports.Responder = Responder;

0 comments on commit 798aefb

Please sign in to comment.