Passing data to step function catch

I wanted to add to @Zachscs answer that you need to be careful when doing "Catch" on "Type": "Map", as this is and doing "ResultPath": "$.error", will throw:

Unable to apply step "error" to input [...]

This makes sense, as the input is an array. You solve it by adding a simple zero-based index to error like this:

"Type": "Map",
"Next": "Finish",
"Catch": [
  {
    "ErrorEquals": [ "States.All" ],
    "Next": "ErrorHandler",
    "Comment": "Note the $[0] down below",
    "ResultPath": "$[0].error"
  }
]

This will append it to the second index of the array $[1].error


I found an answer, you can use ResultPath to pass the original input along with the error. I suppose I will include the step as a property in all inputs so that I can know what step failed. See the docs for an explanation. Essentially to accomplish this you would just add the ResultPath property like so:

"Catch": [
  {
    "ErrorEquals": [ "States.All" ],
    "Next": "ErrorHandler"
    "ResultPath": "$.error"
  }
]