Package com.univocity.parsers.common
Class AbstractException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- com.univocity.parsers.common.AbstractException
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
TextParsingException
,TextWritingException
abstract class AbstractException extends java.lang.RuntimeException
Parent class of the Exception classes thrown by univocity-parsers. This class provides utility methods to print out the internal state of the parser/writer at the time an error occurred.
-
-
Field Summary
Fields Modifier and Type Field Description protected int
errorContentLength
private static long
serialVersionUID
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractException(java.lang.String message, java.lang.Throwable cause)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract 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 abstract 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.protected 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.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
errorContentLength
protected int errorContentLength
-
-
Method Detail
-
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.
-
getDetails
protected abstract 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 thegetMessage()
method to print out these details after the error message.- Returns:
- a String describing the internal state of the parser/writer.
-
getErrorDescription
protected abstract java.lang.String getErrorDescription()
Returns a generic description of the error. The result of this method is used bygetMessage()
to print out a general description of the error before a detailed message of the root cause.- Returns:
- a generic description of 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)
-
-