Class ExceptionWithContext

    • Constructor Detail

      • ExceptionWithContext

        public ExceptionWithContext​(String message)
        Constructs an instance.
        Parameters:
        message - human-oriented message
      • ExceptionWithContext

        public ExceptionWithContext​(Throwable cause)
        Constructs an instance.
        Parameters:
        cause - null-ok; exception that caused this one
      • ExceptionWithContext

        public ExceptionWithContext​(String message,
                                    Throwable cause)
        Constructs an instance.
        Parameters:
        message - human-oriented message
        cause - null-ok; exception that caused this one
    • Method Detail

      • withContext

        public static ExceptionWithContext withContext​(Throwable ex,
                                                       String str)
        Augments the given exception with the given context, and return the result. The result is either the given exception if it was an ExceptionWithContext, or a newly-constructed exception if it was not.
        Parameters:
        ex - non-null; the exception to augment
        str - non-null; context to add
        Returns:
        non-null; an appropriate instance
      • printStackTrace

        public void printStackTrace​(PrintStream out)
        Writes a printable representation of this Throwable's stack trace to the given print stream. If the Throwable contains a cause, the method will be invoked recursively for the nested Throwable.
        Overrides:
        printStackTrace in class Throwable
      • printStackTrace

        public void printStackTrace​(PrintWriter out)
        Writes a printable representation of this Throwable's stack trace to the specified print writer. If the Throwable contains a cause, the method will be invoked recursively for the nested Throwable.
        Overrides:
        printStackTrace in class Throwable
        Parameters:
        out - the writer to write the stack trace on.
      • addContext

        public void addContext​(String str)
        Adds a line of context to this instance.
        Parameters:
        str - non-null; new context
      • getContext

        public String getContext()
        Gets the context.
        Returns:
        non-null; the context
      • printContext

        public void printContext​(PrintStream out)
        Prints the message and context.
        Parameters:
        out - non-null; where to print to
      • printContext

        public void printContext​(PrintWriter out)
        Prints the message and context.
        Parameters:
        out - non-null; where to print to