Would like to add my thanks to Stefan as this has helped me out also.
Whilst the error was useful, I had quite a large function and the error message was still a little ambiguous as to where the actual problem lied.
So for those that experience the same, within the script that's erroring, you can also just attach whatever you need to the workflowContext, e.g.
workflowContext.currentRun.errorObj = JSON.stringify(x);
Then in your Slack error handler just add this to the bottom.