title: Java OpenCSV how to catch exceptions / errors with HeaderColumnNameTranslateMappingStrategy
body: <p>While trying to produce errors it's easy to produce one if you give a String when it should be a double or integer which leads to this error:</p>
  
  <pre><code>Exception in thread "pool-2-thread-5" Exception in thread "pool-2-thread-8" java.lang.RuntimeException: com.opencsv.exceptions.CsvDataTypeMismatchException: Konvertierung von OBST &amp; GEMÜSE in double fehlgeschlagen.
      at com.opencsv.bean.concurrent.ProcessCsvLine.run(ProcessCsvLine.java:99)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      at java.lang.Thread.run(Thread.java:748)
  Caused by: com.opencsv.exceptions.CsvDataTypeMismatchException: Konvertierung von OBST &amp; GEMÜSE in double fehlgeschlagen.
      at com.opencsv.bean.ConverterPrimitiveTypes.convertToRead(ConverterPrimitiveTypes.java:128)
      at com.opencsv.bean.BeanFieldSingleValue.convert(BeanFieldSingleValue.java:98)
      at com.opencsv.bean.AbstractBeanField.setFieldValue(AbstractBeanField.java:180)
      at com.opencsv.bean.AbstractMappingStrategy.setFieldValue(AbstractMappingStrategy.java:581)
      at com.opencsv.bean.AbstractMappingStrategy.populateNewBean(AbstractMappingStrategy.java:328)
      at com.opencsv.bean.concurrent.ProcessCsvLine.processLine(ProcessCsvLine.java:128)
      at com.opencsv.bean.concurrent.ProcessCsvLine.run(ProcessCsvLine.java:83)
      ... 3 more
  Caused by: org.apache.commons.beanutils.ConversionException: Error converting from 'String' to 'Double' For input string: "OBST &amp; GEMÜSE"
      at org.apache.commons.beanutils.converters.AbstractConverter.handleError(AbstractConverter.java:282)
      at org.apache.commons.beanutils.converters.AbstractConverter.convert(AbstractConverter.java:177)
      at org.apache.commons.beanutils.converters.ConverterFacade.convert(ConverterFacade.java:61)
      at org.apache.commons.beanutils.ConvertUtilsBean.convert(ConvertUtilsBean.java:491)
      at com.opencsv.bean.ConverterPrimitiveTypes.convertToRead(ConverterPrimitiveTypes.java:118)
      ... 9 more
  Caused by: java.lang.NumberFormatException: For input string: "OBST &amp; GEMÜSE"
      at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2043)
      at sun.misc.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
      at java.lang.Double.parseDouble(Double.java:538)
      at java.lang.Double.&lt;init&gt;(Double.java:608)
      at org.apache.commons.beanutils.converters.NumberConverter.toNumber(NumberConverter.java:448)
      at org.apache.commons.beanutils.converters.NumberConverter.convertToType(NumberConverter.java:271)
      at org.apache.commons.beanutils.converters.AbstractConverter.convert(AbstractConverter.java:169)
      ... 12 more
  </code></pre>
  
  <p>My code looks like this:</p>
  
  <pre class="lang-java prettyprint-override"><code>    for (Entry&lt;Class&lt;?&gt;, Map&lt;String, String&gt;&gt; entry : csvColumnTranslateMap.entrySet()) {
  
          @SuppressWarnings("rawtypes")
          HeaderColumnNameTranslateMappingStrategy strategy = new HeaderColumnNameTranslateMappingStrategy();
          strategy.setType(entry.getKey());
          strategy.setColumnMapping(entry.getValue());
  
          Reader reader = new InputStreamReader(file.getInputStream());
  
          CSVParser parser = new CSVParserBuilder().withSeparator(delimiter).withIgnoreQuotations(false).build();
  
          CSVReader csvReader = new CSVReaderBuilder(reader).withSkipLines(0).withCSVParser(parser).build();
  
          CsvToBean&lt;?&gt; csvToBean = new CsvToBean&lt;&gt;();
  
          csvToBean.setMappingStrategy(strategy);
          csvToBean.setCsvReader(csvReader);
  
          List&lt;?&gt; parsedRows = csvToBean.parse();
  
          if (entry.getKey().equals(Article.class)) {
              databaseConnector.saveAllArticles((List&lt;Article&gt;) parsedRows, articleRepository);
          } else if (entry.getKey().equals(CommidityGroup.class)) {
              databaseConnector.saveAllCommidityGroups((List&lt;CommidityGroup&gt;) parsedRows, commidityGroupRepository);
          } else if (entry.getKey().equals(Promotion.class)) {
              databaseConnector.saveAllPromotions((List&lt;Promotion&gt;) parsedRows, promotionRepository);
          } else if (entry.getKey().equals(Receipt.class)) {
              databaseConnector.saveAllReceipts((List&lt;Receipt&gt;) parsedRows, receiptRepository);
          } else if (entry.getKey().equals(Shop.class)) {
              databaseConnector.saveAllShops((List&lt;Shop&gt;) parsedRows, shopRepository);
          } else {
              System.err.println("Something went wrong");
          }
  
      }
  </code></pre>
  
  <p>How can I catch it or check it even before? I tried the attempt of this site <a href="https://sourceforge.net/p/opencsv/bugs/154/" rel="nofollow noreferrer">https://sourceforge.net/p/opencsv/bugs/154/</a> but didn't helped me.</p>