title: how to access error information in Step Function from previous Function in Catch state
body: <p>I am wondering how to access the cause of my custom exception raised inside my lambda function. I need to access it at the end of my Step Functions workflow, as shown below.</p>
  <p>The diagram below is an example of a failed execution. The error (<code>error-info</code> object, with its' own <code>Error</code> and <code>Cause</code> sections) is found in the output of <code>ParseTextractOutput</code>, but I am wondering how to access it in <code>OutputNotFound</code> as shown below.</p>
  <h3>Step Functions Diagram</h3>
  <p><a href="https://i.stack.imgur.com/0ahY5.png" rel="noreferrer"><img src="https://i.stack.imgur.com/0ahY5.png" alt="enter image description here" /></a></p>
  <h3>Output</h3>
  <p>The output of <code>ParseTextractOutput</code> is</p>
  <pre><code>{
    &quot;event&quot;...
    &quot;error-info&quot;: {
      &quot;Error&quot;: &quot;OutputNotFoundException&quot;,
      &quot;Cause&quot;: &quot;{\&quot;errorMessage\&quot;: \&quot;Contents of Textracted file: {...}}&quot;
      }
    }
  }
  </code></pre>
  <p>I'd like to access this data somehow in these fields (of the Step Functions definition):</p>
  <pre><code>...
    &quot;States&quot;: {
      &quot;OutputNotFound&quot;: {
        &quot;Type&quot;: &quot;Fail&quot;,
        &quot;Error&quot;: &quot;&lt;useful stuff here, like $.error-info.Error or something&gt;&quot;,
        &quot;Cause&quot;: &quot;&lt;useful stuff here, like $.error-info.Cause or something&gt;&quot;
      },
  ...
      &quot;ParseTextractOutput&quot;: {
        &quot;Type&quot;: &quot;Task&quot;,
        &quot;Resource&quot;: &quot;functionARN&quot;,
        &quot;Catch&quot;: [
          {
            &quot;ErrorEquals&quot;: [&quot;OutputNotFoundException&quot;],
            &quot;ResultPath&quot;: &quot;$.error-info&quot;,
            &quot;Next&quot;: &quot;OutputNotFound&quot;
          }
        ],
        &quot;End&quot;: true
      }
  </code></pre>
  <h3>Python Code</h3>
  <p>Here's the relevant code for the Function <code>ParseTextractOutput</code>.</p>
  <pre><code>class OutputNotFoundException(Exception):
    pass
  
  ...
  
  try:
    blocks = data['Blocks']
  except KeyError as e:
    raise OutputNotFoundException('Contents of Textracted file: {}'.format(data))
  </code></pre>