Class DomTripException

  • All Implemented Interfaces:
    java.io.Serializable

    public class DomTripException
    extends java.lang.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:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int position  
      protected java.lang.String xmlContent  
    • Constructor Summary

      Constructors 
      Constructor Description
      DomTripException​(java.lang.String message)
      Creates a new DomTripException with the specified message.
      DomTripException​(java.lang.String message, int position, java.lang.String xmlContent)
      Creates a new DomTripException with the specified message.
      DomTripException​(java.lang.String message, java.lang.Throwable cause)
      Creates a new DomTripException with the specified message and cause.
      DomTripException​(java.lang.Throwable cause)
      Creates a new DomTripException with the specified cause.
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      int getPosition()
      Deprecated.
      Use position() instead.
      java.lang.String getXmlContent()
      Deprecated.
      Use xmlContent() instead.
      int position()
      Gets the character position where the parsing error occurred.
      java.lang.String xmlContent()
      Gets the XML content that was being parsed when the error occurred.
      • Methods inherited from class java.lang.Throwable

        addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, 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

      • position

        protected final int position
      • xmlContent

        protected final java.lang.String xmlContent
    • Constructor Detail

      • DomTripException

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

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

        public DomTripException​(java.lang.String message,
                                java.lang.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​(java.lang.Throwable cause)
        Creates a new DomTripException with the specified cause.
        Parameters:
        cause - the underlying cause of this exception
    • Method Detail

      • 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 java.lang.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 java.lang.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