Code and Slack: Try-Catch Error Notifier Wrapper Template

This Spojit template wraps a risky step in a try-catch, posts a structured error to Slack when it fails, and lets the rest of the workflow keep running.

What It Builds

This template uses a Manual trigger and the code connector to run a risky step inside a try-catch block, catching any error instead of letting it halt the run. When the step throws, a Slack Connector node posts a structured message (step name, error text, and timestamp) to a chosen channel, then the workflow continues with a safe fallback value. When the step succeeds, no alert fires and the result flows downstream as normal.

It is the graceful-degradation wrapper: instead of a failed run blocking everything after it, the failure is contained, reported to your team in Slack, and the workflow carries on. You can drop this pattern around any single step you do not want to be a hard stop.

The Prompt

Paste this into Miraxa, the intelligent layer across your automation, and it builds the workflow and connects the tools for you:

Build a manually triggered workflow that runs a risky step inside a try-catch using the code connector's execute-javascript tool. If the step throws an error, catch it and post a structured message to the #alerts Slack channel containing the step name, the error message, and the timestamp, then return a safe fallback value so the rest of the workflow keeps running. If the step succeeds, skip the Slack alert and pass the result through.

Connectors Used

  • code - the execute-javascript tool wraps the risky logic in a try-catch and returns either the result or a caught error object. Runs in a Connector node in Direct mode (no AI credits).
  • slack - the send-message tool posts the structured failure alert to your channel. Runs in a Connector node in Direct mode.
  • Trigger - Manual, so you run it on demand with the Run button. Swap to a Schedule or Webhook trigger later if you want it to run automatically.

Customize It

The obvious knobs to change in the prompt before pasting: the Slack channel (replace #alerts with your own), what counts as the risky step (describe the actual call you want wrapped, such as an external API request or a parse), and the fallback value the catch branch returns. You can also ask Miraxa to add a Condition node after the catch so the alert only fires for certain error types, all without a second prompt.

Tips

  • Keep both nodes in Direct mode: the try-catch and the Slack post are deterministic, so you avoid AI credits and get predictable behavior.
  • Reference the caught error in your Slack message with variables like {{ step.error }} and a generated timestamp so the alert is actionable, not just "something failed".
  • For the Slack send-message call, confirm your Slack connection has access to the target channel and that the channel name or ID matches exactly.

Common Pitfalls

  • The whole point is that the catch swallows the error: if you want some failures to still stop the run, add a Condition node so critical errors re-raise instead of being silently absorbed.
  • If the Slack alert never arrives, check that the bot user behind your Slack connection is a member of the channel; private channels need an explicit invite.
  • Returning an empty fallback can hide a problem downstream. Pick a fallback value that downstream nodes can clearly recognize as "degraded" rather than a real result.

Related Articles

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.