Class AbstractException

All Implemented Interfaces:
Serializable
Direct Known Subclasses:
TextParsingException, TextWritingException

abstract class AbstractException extends 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 Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • errorContentLength

      protected int errorContentLength
  • Constructor Details

    • AbstractException

      protected AbstractException(String message, Throwable cause)
  • Method Details

    • 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.
    • getDetails

      protected abstract 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 abstract 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.
    • 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)