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:
Serializable
- Direct Known Subclasses:
TextParsingException,TextWritingException
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
FieldsModifier and TypeFieldDescriptionprotected intprivate static final long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract StringSubclasses must implement this method to return as much information as possible about the internal state of the parser/writer.protected abstract StringReturns a generic description of the error.final StringReturns a detailed message describing the error, and the internal state of the parser/writer.protected static StringprintIfNotEmpty(String previous, String description, Object o) static StringrestrictContent(int errorContentLength, CharSequence content) static Object[]restrictContent(int errorContentLength, Object[] content) protected StringrestrictContent(CharSequence content) protected StringrestrictContent(Object content) protected Object[]restrictContent(Object[] content) voidsetErrorContentLength(int errorContentLength) protected StringupdateMessage(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
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
errorContentLength
protected int errorContentLength
-
-
Constructor Details
-
AbstractException
-
-
Method Details
-
getMessage
Returns a detailed message describing the error, and the internal state of the parser/writer.- Overrides:
getMessagein classThrowable- Returns:
- a detailed message describing the error
-
updateMessage
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
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
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
-
restrictContent
-
restrictContent
-
setErrorContentLength
public void setErrorContentLength(int errorContentLength) -
restrictContent
-
restrictContent
-
restrictContent
-