How to skip custom FieldSetMapper in spring-batch Step?
<p>I want to throw a custom exception within a <code>FieldSetMapper</code>, and ignore it in the <code>Step</code> with <code>skip()</code>:</p>

<pre><code>@Bean
public Step step() {
    return stepBuilder.get(name).faultTolerant().skip(MyException.class).reader(..).processor(..).writer(..).build();
}
</code></pre>



<pre><code>private FieldSetMapper&lt;TravelitHotelEntity&gt; prepareFieldMapper() {
    return new FieldSetMapper&lt;MyEntity&gt;() {
        @Override
        public MyEntity mapFieldSet(FieldSet fieldSet) throws BindException {
            throw new MyException("test");
        }
    };
}
</code></pre>

<p>Result: the job terminates saying:</p>

<blockquote>
  <p>Caused by: org.springframework.batch.item.file.FlatFileParseException:
  Parsing error at line: 2... Caused by: MyException: ...</p>
</blockquote>

<p>This is because <code>MyException</code> somehow gets wrapped inside the <code>FlatFileParseException</code> and thus is not detected by the <code>skip()</code>. But I don't want to add the <code>FlatFileParseException</code> as skippable exception as there might of course be cases where I don't want to ignore it.</p>

<p>What can be done here?</p>