Package com.univocity.parsers.common
Class TextWritingException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- com.univocity.parsers.common.TextWritingException
-
- All Implemented Interfaces:
java.io.Serializable
public class TextWritingException extends java.lang.RuntimeException
Exception type used provide information about any issue that might happen while writing to a given output.It generally provides location and data information in case of a writing failure.
- Author:
- Univocity Software Pty Ltd - parsers@univocity.com
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected int
errorContentLength
-
Constructor Summary
Constructors Constructor Description TextWritingException(java.lang.String message)
Creates a new exception with information about an error that occurred when writing data to some output.TextWritingException(java.lang.String message, long line, java.lang.Object[] row)
Creates a new exception with information about an error that occurred when writing data to some output.TextWritingException(java.lang.String message, long recordCount, java.lang.Object[] row, java.lang.Throwable cause)
Creates a new exception with information about an error that occurred when writing data to some output.TextWritingException(java.lang.String message, long line, java.lang.String recordCharacters)
Creates a new exception with information about an error that occurred when writing data to some output.TextWritingException(java.lang.String message, long recordCount, java.lang.String recordCharacters, java.lang.Throwable cause)
Creates a new exception with information about an error that occurred when writing data to some output.TextWritingException(java.lang.Throwable cause)
Creates a new exception with information about an error that occurred when writing data to some output.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.java.lang.String
getMessage()
Returns a detailed message describing the error, and the internal state of the parser/writer.java.lang.String
getRecordCharacters()
Returns the character data that failed to be writtenlong
getRecordCount()
Returns the number of records written before the exception occurred.java.lang.Object[]
getRecordData()
Returns the data that failed to be writtenprotected static java.lang.String
printIfNotEmpty(java.lang.String previous, java.lang.String description, java.lang.Object o)
static java.lang.String
restrictContent(int errorContentLength, java.lang.CharSequence content)
static java.lang.Object[]
restrictContent(int errorContentLength, java.lang.Object[] content)
protected java.lang.String
restrictContent(java.lang.CharSequence content)
protected java.lang.String
restrictContent(java.lang.Object content)
protected java.lang.Object[]
restrictContent(java.lang.Object[] content)
void
setErrorContentLength(int errorContentLength)
protected java.lang.String
updateMessage(java.lang.String msg)
Allows subclasses to alter the exception message that should be displayed to end users.
-
-
-
Constructor Detail
-
TextWritingException
public TextWritingException(java.lang.String message, long recordCount, java.lang.String recordCharacters, java.lang.Throwable cause)
Creates a new exception with information about an error that occurred when writing data to some output.- Parameters:
message
- message with details about the errorrecordCount
- the number of records written until the error occurredrecordCharacters
- the characters already written to the output record.cause
- the cause of the error
-
TextWritingException
public TextWritingException(java.lang.String message, long recordCount, java.lang.Object[] row, java.lang.Throwable cause)
Creates a new exception with information about an error that occurred when writing data to some output.- Parameters:
message
- message with details about the errorrecordCount
- the number of records written until the error occurredrow
- the input row that was being written when the error occurredcause
- the cause of the error
-
TextWritingException
public TextWritingException(java.lang.String message)
Creates a new exception with information about an error that occurred when writing data to some output.- Parameters:
message
- message with details about the error
-
TextWritingException
public TextWritingException(java.lang.Throwable cause)
Creates a new exception with information about an error that occurred when writing data to some output.- Parameters:
cause
- the cause of the error
-
TextWritingException
public TextWritingException(java.lang.String message, long line, java.lang.Object[] row)
Creates a new exception with information about an error that occurred when writing data to some output.- Parameters:
message
- message with details about the errorline
- index of the line being written to the output when the error occurredrow
- the input row that was being written when the error occurred
-
TextWritingException
public TextWritingException(java.lang.String message, long line, java.lang.String recordCharacters)
Creates a new exception with information about an error that occurred when writing data to some output.- Parameters:
message
- message with details about the errorline
- index of the line being written to the output when the error occurredrecordCharacters
- the characters already written to the output record.
-
-
Method Detail
-
getRecordCount
public long getRecordCount()
Returns the number of records written before the exception occurred.- Returns:
- the number of records written before the exception occurred.
-
getRecordData
public java.lang.Object[] getRecordData()
Returns the data that failed to be written- Returns:
- the data that failed to be written
-
getRecordCharacters
public java.lang.String getRecordCharacters()
Returns the character data that failed to be written- Returns:
- the character data that failed to be written
-
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.- Returns:
- a String describing the internal state of the parser/writer.
-
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.- Returns:
- a generic description of the error.
-
getMessage
public final java.lang.String getMessage()
Returns a detailed message describing the error, and the internal state of the parser/writer.- Overrides:
getMessage
in classjava.lang.Throwable
- Returns:
- a detailed message describing the error
-
updateMessage
protected 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.
-
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)
-
-