Class AdfException

    • Field Detail

      • NODE_PREFIX

        public static final String NODE_PREFIX
        Used in exception backtraces to introduce the node's type after any preceding information about where the node was found.

        Example: doc[0].paragraph[0].text:marks[1].code
        The periods (.) before paragraph and text are node prefixes.

        See Also:
        Constant Field Values
      • MARK_PREFIX

        public static final String MARK_PREFIX
        Used in exception backtraces to introduce the mark's type after any preceding information about where the mark was found.

        Example: doc[0].paragraph[0].text:marks[1].code
        The period (.) before code is a mark prefix.

        See Also:
        Constant Field Values
      • MARKS_PREFIX

        public static final String MARKS_PREFIX
        Used in exception backtraces to indicate that the problem occurs within a node's marks fields rather than elsewhere in the node's information.

        Example: doc[0].paragraph[0].text:marks[1].code
        The :marks portion indicates that the text node's marks were at fault, and specifically the one at index [1], meaning the second mark.

        See Also:
        Constant Field Values
    • Constructor Detail

      • AdfException

        protected AdfException​(String message)
      • AdfException

        protected AdfException​(String message,
                               @Nullable
                               Throwable cause)
    • Method Detail

      • frame

        public static <T> T frame​(String frame,
                                  Supplier<T> supplier)
        Wraps code that calculates a value with a catch block that will add the specified frame to the backtrace(String) if that code throws a runtime exception.
        Type Parameters:
        T - the inferred return type of the supplier
        Parameters:
        frame - the frame information to be added to the backtrace if an exception is thrown
        supplier - the code that generates the requested value
        Returns:
        the supplied value
        Throws:
        AdfException - with frame added to the backtrace if any RuntimeException is thrown by the supplier
      • backtrace

        public final AdfException backtrace​(String frame)
        Adds the given frame to the backtrace for this exception. The backtrace is used to provide the path when rendering an AdfException.
        Parameters:
        frame - the frame information to add to this exception's backtrace
        Returns:
        this
      • getPath

        @Nullable
        public String getPath()
        Returns the current path information for this exception, if it is available. The path is formed by concatenating all of the frame values that were provided by frame(String, Supplier) or backtrace(String) calls, in reverse order.
        Returns:
        the path information for this exception, or null if none has been provided