Class DataProcessingException

  • All Implemented Interfaces:
    java.io.Serializable
    Direct Known Subclasses:
    DataValidationException

    public class DataProcessingException
    extends TextParsingException
    A DataProcessingException is an error thrown during the processing of a record successfully parsed. This type of error usually indicates that the input text has been parsed correctly, but the subsequent transformations applied over the input (generally via a RowProcessor} failed.
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      DataProcessingException​(java.lang.String message)
      Creates a new exception with an error message only.
      DataProcessingException​(java.lang.String message, int columnIndex)
      Creates a new exception with an error message and the column that could not be processed.
      DataProcessingException​(java.lang.String message, int columnIndex, java.lang.Object[] row, java.lang.Throwable cause)
      Creates a new exception with an error message, the column that could not be processed the row that could not be processed, and the error cause.
      DataProcessingException​(java.lang.String message, java.lang.Object[] row)
      Creates a new exception with an error message and the row that could not be processed.
      DataProcessingException​(java.lang.String message, java.lang.Object[] row, java.lang.Throwable cause)
      Creates a new exception with an error message, the row that could not be processed, and the error cause.
      DataProcessingException​(java.lang.String message, java.lang.Throwable cause)
      Creates a new exception with an error message and error cause
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getColumnIndex()
      Returns the index of the column from where the error occurred, if available.
      java.lang.String getColumnName()
      Returns the name of the column from where the error occurred, if available.
      protected java.lang.String getDetails()
      Subclasses must implement this method to return as much information as possible about the internal state of the parser/writer.
      protected java.lang.String getErrorDescription()
      Returns a generic description of the error.
      private int getExtractedColumnIndex()  
      java.lang.Object[] getRow()
      Returns the record being processed when the error occurred, if available.
      java.lang.Object getValue()
      Returns the value being processed when the error occurred, if available.
      (package private) boolean isFatal()
      Returns a flag indicating whether this error is fatal and the process must stop as it is impossible to proceed.
      boolean isHandled()
      Returns a flag indicating this exception has been handled by a user-provided ProcessorErrorHandler
      void markAsHandled​(ProcessorErrorHandler handler)
      Marks the error as handled so it doesn't trigger a ProcessorErrorHandler again.
      void markAsNonFatal()
      Marks the error as non fatal and the parsing process might proceed.
      void setColumnIndex​(int columnIndex)
      Defines the column index being processed when the error occurred.
      void setColumnName​(java.lang.String columnName)
      Defines the name of the column being processed when the error occurred.
      void setDetails​(java.lang.String details)  
      void setRow​(java.lang.Object[] row)
      Updates the exception with the record being processed when the error occurred.
      void setValue​(java.lang.Object value)
      Defines the value being processed when the error occurred.
      void setValue​(java.lang.String label, java.lang.Object value)
      Associates a label in the exception message (idenfied in curly braces) with a value being processed when the error occurred.
      protected java.lang.String updateMessage​(java.lang.String msg)
      Allows subclasses to alter the exception message that should be displayed to end users.
      • Methods inherited from class java.lang.Throwable

        addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • columnName

        private java.lang.String columnName
      • columnIndex

        private int columnIndex
      • row

        private java.lang.Object[] row
      • value

        private java.lang.Object value
      • values

        private java.util.Map<java.lang.String,​java.lang.Object> values
      • fatal

        private boolean fatal
      • handled

        private boolean handled
      • details

        private java.lang.String details
    • Constructor Detail

      • DataProcessingException

        public DataProcessingException​(java.lang.String message)
        Creates a new exception with an error message only.
        Parameters:
        message - the error message
      • DataProcessingException

        public DataProcessingException​(java.lang.String message,
                                       java.lang.Throwable cause)
        Creates a new exception with an error message and error cause
        Parameters:
        message - the error message
        cause - the cause of the error
      • DataProcessingException

        public DataProcessingException​(java.lang.String message,
                                       java.lang.Object[] row)
        Creates a new exception with an error message and the row that could not be processed.
        Parameters:
        message - the error message
        row - the row that could not be processed.
      • DataProcessingException

        public DataProcessingException​(java.lang.String message,
                                       java.lang.Object[] row,
                                       java.lang.Throwable cause)
        Creates a new exception with an error message, the row that could not be processed, and the error cause.
        Parameters:
        message - the error message
        row - the row that could not be processed.
        cause - the cause of the error
      • DataProcessingException

        public DataProcessingException​(java.lang.String message,
                                       int columnIndex)
        Creates a new exception with an error message and the column that could not be processed.
        Parameters:
        message - the error message
        columnIndex - index of the column that could not be processed.
      • DataProcessingException

        public DataProcessingException​(java.lang.String message,
                                       int columnIndex,
                                       java.lang.Object[] row,
                                       java.lang.Throwable cause)
        Creates a new exception with an error message, the column that could not be processed the row that could not be processed, and the error cause.
        Parameters:
        message - the error message
        columnIndex - index of the column that could not be processed.
        row - the row that could not be processed.
        cause - the cause of the error
    • Method Detail

      • getErrorDescription

        protected java.lang.String getErrorDescription()
        Description copied from class: AbstractException
        Returns a generic description of the error. The result of this method is used by AbstractException.getMessage() to print out a general description of the error before a detailed message of the root cause.
        Overrides:
        getErrorDescription in class TextParsingException
        Returns:
        a generic description of the error.
      • getColumnName

        public java.lang.String getColumnName()
        Returns the name of the column from where the error occurred, if available.
        Returns:
        the name of the column from where the error occurred.
      • getColumnIndex

        public final int getColumnIndex()
        Returns the index of the column from where the error occurred, if available.
        Overrides:
        getColumnIndex in class TextParsingException
        Returns:
        the index of the column from where the error occurred.
      • getRow

        public final java.lang.Object[] getRow()
        Returns the record being processed when the error occurred, if available.
        Returns:
        the record being processed when error occurred, if available.
      • setValue

        public final void setValue​(java.lang.Object value)
        Defines the value being processed when the error occurred.
        Parameters:
        value - the value being processed when error occurred.
      • setValue

        public final void setValue​(java.lang.String label,
                                   java.lang.Object value)
        Associates a label in the exception message (idenfied in curly braces) with a value being processed when the error occurred. Used for formatting the exception message
        Parameters:
        label - a label in the exception message - any string enclosed by curly braces.
        value - the value being processed when error occurred, that should be replaced by the label in the exception message.
      • getValue

        public final java.lang.Object getValue()
        Returns the value being processed when the error occurred, if available.
        Returns:
        the value being processed when the error occurred, if available.
      • setColumnIndex

        public final void setColumnIndex​(int columnIndex)
        Defines the column index being processed when the error occurred.
        Parameters:
        columnIndex - the column index being processed when error occurred.
      • getExtractedColumnIndex

        private int getExtractedColumnIndex()
      • setColumnName

        public final void setColumnName​(java.lang.String columnName)
        Defines the name of the column being processed when the error occurred.
        Parameters:
        columnName - the name of the column being processed when error occurred.
      • setRow

        public final void setRow​(java.lang.Object[] row)
        Updates the exception with the record being processed when the error occurred.
        Parameters:
        row - the record data processed when the error occurred.
      • isFatal

        final boolean isFatal()
        Returns a flag indicating whether this error is fatal and the process must stop as it is impossible to proceed.
        Returns:
        a flag indicating whether this error is fatal and the process must stop as it is impossible to proceed.
      • markAsNonFatal

        public final void markAsNonFatal()
        Marks the error as non fatal and the parsing process might proceed.
      • isHandled

        public boolean isHandled()
        Returns a flag indicating this exception has been handled by a user-provided ProcessorErrorHandler
        Returns:
        true if this exception has been handled to a user-provided ProcessorErrorHandler, otherwise false
      • setDetails

        public void setDetails​(java.lang.String details)
      • updateMessage

        protected final java.lang.String updateMessage​(java.lang.String msg)
        Description copied from class: AbstractException
        Allows subclasses to alter the exception message that should be displayed to end users. By default the original message is kept unchanged.
        Overrides:
        updateMessage in class AbstractException
        Parameters:
        msg - the original message
        Returns:
        the updated message.