title: Mule 4 sftp read file - retry mechanism using Until successful , unable to catch exception
body: <p>This question is a followup to an earlier question <a href="https://stackoverflow.com/questions/72199441/mule-4-sftp-read-file-reconnection-strategy-not-working">here</a></p>
  <p>So:
  Am trying to read a file from a SFTP location . Am using Mule 4.4 Community edition. If there is any error while connecting to SFTP server or file is not present , would like mule to retry 2 times .</p>
  <p>Based on answer from @aled I am now using 'until successful'</p>
  <p>Here is the code :</p>
  <pre><code>&lt;sftp:config name=&quot;SFTP_Config&quot; doc:name=&quot;SFTP Config&quot;&gt;
          &lt;sftp:connection host=&quot;abcd&quot; username=&quot;xyz&quot; password=&quot;pwd&quot; /&gt;
      &lt;/sftp:config&gt;
  
  &lt;flow name=&quot;get:employee&quot;&gt;
          &lt;logger level=&quot;INFO&quot; doc:name=&quot;Logger&quot;  message=&quot;starting search&quot; category=&quot;get-employee&quot;/&gt;
          &lt;until-successful maxRetries=&quot;1&quot; doc:name=&quot;Until Successful&quot; millisBetweenRetries=&quot;30000&quot;&gt;
                  &lt;sftp:read doc:name=&quot;Read&quot;  config-ref=&quot;SFTP_Config&quot; path=&quot;/a/employees.unl&quot;&gt;
              &lt;repeatable-in-memory-stream /&gt;
              &lt;reconnect /&gt;
          &lt;/sftp:read&gt;
         &lt;/until-successful&gt;
          &lt;error-handler &gt;&lt;/error-handler&gt;    
  &lt;/flow&gt;
  </code></pre>
  <p>Now the code is retrying to read file from sftp 1 time at an interval of 30 seconds .
  All good till here</p>
  <p>The bit that has got me confused is - error handling .
  In my case I am testing without the file being present in sftp so I get the error :</p>
  <blockquote>
  <p>SFTP:ILLEGAL_PATH</p>
  </blockquote>
  <p>However after max retries the error type is :</p>
  <blockquote>
  <p>SFTP:RETRY_EXHAUSTED</p>
  </blockquote>
  <p>IN error handler when I give the type of error to catch as : SFTP:RETRY_EXHAUSTED
  it is not getting caught !</p>
  <pre><code>&lt;on-error-continue enableNotifications=&quot;false&quot; logException=&quot;false&quot; doc:name=&quot;On Error Continue&quot; type=&quot;SFTP:RETRY_EXHAUSTED&quot;&gt;
  &lt;/on-error-continue&gt;
  </code></pre>
  <p>when I give the catch block to catch both error types:
  SFTP:RETRY_EXHAUSTED and SFTP:ILLEGAL_PATH</p>
  <pre><code>&lt;on-error-continue enableNotifications=&quot;false&quot; logException=&quot;false&quot; doc:name=&quot;On Error Continue&quot;  type=&quot; SFTP:RETRY_EXHAUSTED,SFTP:ILLEGAL_PATH&quot;&gt;
  &lt;/on-error-continue&gt;
  </code></pre>
  <p>The exception is caught but with a warning in log:</p>
  <blockquote>
  <p>Expected error type from flow 'get:employee/errorHandler/2' has
  matched the following underlying error: ILLEGAL_PATH. Consider
  changing it to match the reported error: RETRY_EXHAUSTED.</p>
  </blockquote>
  <p>I am unable to understand this behaviour and what is the best way to do error handling ?</p>