com.univocity.parsers.common
Class TextWritingException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by java.lang.RuntimeException
              extended by com.univocity.parsers.common.TextWritingException
All Implemented Interfaces:
Serializable

public class TextWritingException
extends 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
protected  int errorContentLength
           
 
Constructor Summary
TextWritingException(String message)
          Creates a new exception with information about an error that occurred when writing data to some output.
TextWritingException(String message, long line, Object[] row)
          Creates a new exception with information about an error that occurred when writing data to some output.
TextWritingException(String message, long recordCount, Object[] row, Throwable cause)
          Creates a new exception with information about an error that occurred when writing data to some output.
TextWritingException(String message, long line, String recordCharacters)
          Creates a new exception with information about an error that occurred when writing data to some output.
TextWritingException(String message, long recordCount, String recordCharacters, Throwable cause)
          Creates a new exception with information about an error that occurred when writing data to some output.
TextWritingException(Throwable cause)
          Creates a new exception with information about an error that occurred when writing data to some output.
 
Method Summary
protected  String getDetails()
          Subclasses must implement this method to return as much information as possible about the internal state of the parser/writer.
protected  String getErrorDescription()
          Returns a generic description of the error.
 String getMessage()
          Returns a detailed message describing the error, and the internal state of the parser/writer.
 String getRecordCharacters()
          Returns the character data that failed to be written
 long getRecordCount()
          Returns the number of records written before the exception occurred.
 Object[] getRecordData()
          Returns the data that failed to be written
protected static String printIfNotEmpty(String previous, String description, Object o)
           
protected  String restrictContent(CharSequence content)
           
static String restrictContent(int errorContentLength, CharSequence content)
           
static Object[] restrictContent(int errorContentLength, Object[] content)
           
protected  String restrictContent(Object content)
           
protected  Object[] restrictContent(Object[] content)
           
 void setErrorContentLength(int errorContentLength)
           
protected  String updateMessage(String msg)
          Allows subclasses to alter the exception message that should be displayed to end users.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, 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

errorContentLength

protected int errorContentLength
Constructor Detail

TextWritingException

public TextWritingException(String message,
                            long recordCount,
                            String recordCharacters,
                            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 error
recordCount - the number of records written until the error occurred
recordCharacters - the characters already written to the output record.
cause - the cause of the error

TextWritingException

public TextWritingException(String message,
                            long recordCount,
                            Object[] row,
                            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 error
recordCount - the number of records written until the error occurred
row - the input row that was being written when the error occurred
cause - the cause of the error

TextWritingException

public TextWritingException(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(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(String message,
                            long line,
                            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 error
line - index of the line being written to the output when the error occurred
row - the input row that was being written when the error occurred

TextWritingException

public TextWritingException(String message,
                            long line,
                            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 error
line - index of the line being written to the output when the error occurred
recordCharacters - 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 Object[] getRecordData()
Returns the data that failed to be written

Returns:
the data that failed to be written

getRecordCharacters

public String getRecordCharacters()
Returns the character data that failed to be written

Returns:
the character data that failed to be written

getDetails

protected String getDetails()
Subclasses must implement this method to return as much information as possible about the internal state of the parser/writer. Use printIfNotEmpty(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 the getMessage() method to print out these details after the error message.

Returns:
a String describing the internal state of the parser/writer.

getErrorDescription

protected String getErrorDescription()
Returns a generic description of the error. The result of this method is used by 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 String getMessage()
Returns a detailed message describing the error, and the internal state of the parser/writer.

Overrides:
getMessage in class Throwable
Returns:
a detailed message describing the error

updateMessage

protected String updateMessage(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 String printIfNotEmpty(String previous,
                                        String description,
                                        Object o)

restrictContent

public static String restrictContent(int errorContentLength,
                                     CharSequence content)

restrictContent

public static Object[] restrictContent(int errorContentLength,
                                       Object[] content)

setErrorContentLength

public void setErrorContentLength(int errorContentLength)

restrictContent

protected String restrictContent(CharSequence content)

restrictContent

protected String restrictContent(Object content)

restrictContent

protected Object[] restrictContent(Object[] content)


Copyright © 2017 uniVocity Software Pty Ltd. All rights reserved.