Class DomTripException

All Implemented Interfaces:
Serializable

public class DomTripException extends RuntimeException
Base exception class for all DomTrip-related errors.

DomTripException serves as the exception for all errors that can occur during XML processing with DomTrip. It extends RuntimeException to provide unchecked exception semantics, making the API easier to use while still allowing proper error handling when needed.

Usage Example:

try {
    Editor editor = new Editor(malformedXml);
} catch (DomTripException e) {
    // Handle any DomTrip-related error
    logger.error("XML processing failed: " + e.getMessage(), e);
}

Error Recovery:

When catching DomTripException, consider:

  • Checking the specific exception type for targeted handling
  • Examining the cause for underlying issues
  • Providing meaningful error messages to users
  • Logging sufficient detail for debugging
See Also:
  • Field Details

    • position

      protected final int position
    • xmlContent

      protected final String xmlContent
  • Constructor Details

    • DomTripException

      public DomTripException(String message, int position, String xmlContent)
      Creates a new DomTripException with the specified message.
      Parameters:
      message - the detail message explaining the error
    • DomTripException

      public DomTripException(String message)
      Creates a new DomTripException with the specified message.
      Parameters:
      message - the detail message explaining the error
    • DomTripException

      public DomTripException(String message, Throwable cause)
      Creates a new DomTripException with the specified message and cause.
      Parameters:
      message - the detail message explaining the error
      cause - the underlying cause of this exception
    • DomTripException

      public DomTripException(Throwable cause)
      Creates a new DomTripException with the specified cause.
      Parameters:
      cause - the underlying cause of this exception
  • Method Details

    • position

      public int position()
      Gets the character position where the parsing error occurred.
      Returns:
      the character position, or -1 if position is not available
    • getPosition

      @Deprecated public int getPosition()
      Deprecated.
      Use position() instead.
      Gets the character position where the parsing error occurred.
      Returns:
      the character position, or -1 if position is not available
    • xmlContent

      public String xmlContent()
      Gets the XML content that was being parsed when the error occurred.

      This can be used to provide context around the error position for debugging purposes.

      Returns:
      the XML content, or null if not available
    • getXmlContent

      @Deprecated public String getXmlContent()
      Deprecated.
      Use xmlContent() instead.
      Gets the XML content that was being parsed when the error occurred.
      Returns:
      the XML content, or null if not available