Package org.jf.util

Class ExceptionWithContext

    • Constructor Summary

      Constructors 
      Constructor Description
      ExceptionWithContext​(java.lang.String message, java.lang.Object... formatArgs)
      Constructs an instance.
      ExceptionWithContext​(java.lang.Throwable cause)
      Constructs an instance.
      ExceptionWithContext​(java.lang.Throwable cause, java.lang.String message, java.lang.Object... formatArgs)
      Constructs an instance.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addContext​(java.lang.String str)
      Adds a line of context to this instance.
      java.lang.String getContext()
      Gets the context.
      void printContext​(java.io.PrintStream out)
      Prints the message and context.
      void printContext​(java.io.PrintWriter out)
      Prints the message and context.
      void printStackTrace​(java.io.PrintStream out)
      void printStackTrace​(java.io.PrintWriter out)
      static ExceptionWithContext withContext​(java.lang.Throwable ex, java.lang.String str, java.lang.Object... formatArgs)
      Augments the given exception with the given context, and return the result.
      • Methods inherited from class java.lang.Throwable

        addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, setStackTrace, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • ExceptionWithContext

        public ExceptionWithContext​(java.lang.String message,
                                    java.lang.Object... formatArgs)
        Constructs an instance.
        Parameters:
        message - human-oriented message
      • ExceptionWithContext

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

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

      • withContext

        public static ExceptionWithContext withContext​(java.lang.Throwable ex,
                                                       java.lang.String str,
                                                       java.lang.Object... formatArgs)
        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​(java.io.PrintStream out)
        Overrides:
        printStackTrace in class java.lang.Throwable
      • printStackTrace

        public void printStackTrace​(java.io.PrintWriter out)
        Overrides:
        printStackTrace in class java.lang.Throwable
      • addContext

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

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

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

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