Package com.univocity.parsers.common
Class DataProcessingException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- com.univocity.parsers.common.TextParsingException
-
- com.univocity.parsers.common.DataProcessingException
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
DataValidationException
public class DataProcessingException extends TextParsingException
ADataProcessingExceptionis 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 aRowProcessor} failed.- Author:
- Univocity Software Pty Ltd - parsers@univocity.com
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected interrorContentLength-
Fields inherited from class com.univocity.parsers.common.TextParsingException
extractedIndexes
-
-
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 Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetColumnIndex()Returns the index of the column from where the error occurred, if available.java.lang.StringgetColumnName()Returns the name of the column from where the error occurred, if available.protected java.lang.StringgetDetails()Subclasses must implement this method to return as much information as possible about the internal state of the parser/writer.protected java.lang.StringgetErrorDescription()Returns a generic description of the error.java.lang.StringgetMessage()Returns a detailed message describing the error, and the internal state of the parser/writer.java.lang.Object[]getRow()Returns the record being processed when the error occurred, if available.java.lang.ObjectgetValue()Returns the value being processed when the error occurred, if available.booleanisHandled()Returns a flag indicating this exception has been handled by a user-providedProcessorErrorHandlervoidmarkAsHandled(ProcessorErrorHandler handler)Marks the error as handled so it doesn't trigger aProcessorErrorHandleragain.voidmarkAsNonFatal()Marks the error as non fatal and the parsing process might proceed.protected static java.lang.StringprintIfNotEmpty(java.lang.String previous, java.lang.String description, java.lang.Object o)static java.lang.StringrestrictContent(int errorContentLength, java.lang.CharSequence content)static java.lang.Object[]restrictContent(int errorContentLength, java.lang.Object[] content)protected java.lang.StringrestrictContent(java.lang.CharSequence content)protected java.lang.StringrestrictContent(java.lang.Object content)protected java.lang.Object[]restrictContent(java.lang.Object[] content)voidsetColumnIndex(int columnIndex)Defines the column index being processed when the error occurred.voidsetColumnName(java.lang.String columnName)Defines the name of the column being processed when the error occurred.voidsetDetails(java.lang.String details)voidsetErrorContentLength(int errorContentLength)voidsetRow(java.lang.Object[] row)Updates the exception with the record being processed when the error occurred.voidsetValue(java.lang.Object value)Defines the value being processed when the error occurred.voidsetValue(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.StringupdateMessage(java.lang.String msg)Allows subclasses to alter the exception message that should be displayed to end users.-
Methods inherited from class com.univocity.parsers.common.TextParsingException
getCharIndex, getHeaders, getLineIndex, getParsedContent, getRecordNumber, setContext
-
-
-
-
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 messagecause- 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 messagerow- 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 messagerow- 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 messagecolumnIndex- 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 messagecolumnIndex- 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()
Returns a generic description of the error. The result of this method is used byThrowable.getMessage()to print out a general description of the error before a detailed message of the root cause.- Overrides:
getErrorDescriptionin classTextParsingException- Returns:
- a generic description of the error.
-
getDetails
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. UseprintIfNotEmpty(String, String, Object)to create a comma-separated list of relevant properties and their (non null) values. The result of this method is used by theThrowable.getMessage()method to print out these details after the error message.- Overrides:
getDetailsin classTextParsingException- Returns:
- a String describing the internal state of the parser/writer.
-
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:
getColumnIndexin classTextParsingException- 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.
-
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.
-
markAsNonFatal
public final void markAsNonFatal()
Marks the error as non fatal and the parsing process might proceed.
-
markAsHandled
public final void markAsHandled(ProcessorErrorHandler handler)
Marks the error as handled so it doesn't trigger aProcessorErrorHandleragain.- Parameters:
handler- theProcessorErrorHandlerused to handle this exception.
-
isHandled
public boolean isHandled()
Returns a flag indicating this exception has been handled by a user-providedProcessorErrorHandler- Returns:
trueif this exception has been handled to a user-providedProcessorErrorHandler, otherwisefalse
-
setDetails
public void setDetails(java.lang.String details)
-
updateMessage
protected final java.lang.String updateMessage(java.lang.String msg)
Allows subclasses to alter the exception message that should be displayed to end users. By default the original message is kept unchanged.- Parameters:
msg- the original message- Returns:
- the updated message.
-
getMessage
public final java.lang.String getMessage()
Returns a detailed message describing the error, and the internal state of the parser/writer.- Overrides:
getMessagein classjava.lang.Throwable- Returns:
- a detailed message describing the error
-
printIfNotEmpty
protected static java.lang.String printIfNotEmpty(java.lang.String previous, java.lang.String description, java.lang.Object o)
-
restrictContent
public static java.lang.String restrictContent(int errorContentLength, java.lang.CharSequence content)
-
restrictContent
public static java.lang.Object[] restrictContent(int errorContentLength, java.lang.Object[] content)
-
setErrorContentLength
public void setErrorContentLength(int errorContentLength)
-
restrictContent
protected java.lang.String restrictContent(java.lang.CharSequence content)
-
restrictContent
protected java.lang.String restrictContent(java.lang.Object content)
-
restrictContent
protected java.lang.Object[] restrictContent(java.lang.Object[] content)
-
-