Top Description Fields Constructors Methods
com.opencsv.bean.exceptionhandler

public final Class ExceptionHandlerIgnoreThenThrowAfter

extends Object
implements CsvExceptionHandler
Class Inheritance
All Implemented Interfaces
com.opencsv.bean.exceptionhandler.CsvExceptionHandler
Imports
com.opencsv.exceptions.CsvException, java.util.concurrent.atomic.AtomicInteger

An exception handler that ignores the first x exceptions, then throws any further exceptions.
Author
Andrew Rucker Jones
Since
5.2

Field Summary

Modifier and TypeField and Description
private final AtomicInteger
private final int

Constructor Summary

AccessConstructor and Description
public
ExceptionHandlerIgnoreThenThrowAfter(int
The number of exceptions that will be ignored. Any exception handled after this limit will be thrown.
maxExceptions
)

Creates an instance.

Method Summary

Modifier and TypeMethod and Description
public CsvException
handleException(CsvException e)

Implements com.opencsv.bean.exceptionhandler.CsvExceptionHandler.handleException.

Determines how opencsv will handle exceptions that crop up during bean creation or writing.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

countback to summary
private final AtomicInteger count
maxExceptionsback to summary
private final int maxExceptions

Constructor Detail

ExceptionHandlerIgnoreThenThrowAfterback to summary
public ExceptionHandlerIgnoreThenThrowAfter(int maxExceptions)

Creates an instance.

Parameters
maxExceptions:int

The number of exceptions that will be ignored. Any exception handled after this limit will be thrown.

Method Detail

handleExceptionback to summary
public CsvException handleException(CsvException e) throws CsvException

Implements com.opencsv.bean.exceptionhandler.CsvExceptionHandler.handleException.

Doc from com.opencsv.bean.exceptionhandler.CsvExceptionHandler.handleException.

Determines how opencsv will handle exceptions that crop up during bean creation or writing. There are three ways of dealing with an exception:

  1. Ignore the exception. In this case, return null.
  2. Queue the exception. In this case, return either the original exception thrown, or a new exception that meets your needs better.
  3. Halt processing by throwing the exception. In this case, throw the exception or a new exception that meets your needs better.

Please be cautioned: Due to the multi-threaded nature of opencsv's conversion routines, there is no guarantee that the exception thrown, if your chosen error handler throws exceptions, is the error in the input that would have caused the exception to be thrown if the input were processed in strict sequential order. That is, if there are four errors in the input and your error handler queues the first three but throws the fourth, the exception thrown might relate to any of the four errors in the input.

If your exception handler queues a certain number of exceptions before throwing one, opencsv makes a best-faith effort to make sure all of the exceptions marked for queueing are actually available via CsvToBean#getCapturedExceptions() or StatefulBeanToCsv#getCapturedExceptions() after processing, but there are no absolute guarantees.

This method must be thread-safe.

Annotations
@Override
Exceptions
CsvException:
If a halt to all processing is desired