Class ReportedException

  • All Implemented Interfaces:
    java.io.Serializable

    public class ReportedException
    extends java.lang.RuntimeException
    This is a special exception that cannot be directly thrown.

    It is used to capture more information about an exception that was already thrown.

    Since:
    10285
    See Also:
    BugReport, Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      ReportedException​(java.lang.Throwable exception)
      Constructs a new ReportedException.
      ReportedException​(java.lang.Throwable exception, java.lang.Thread caughtOnThread)
      Constructs a new ReportedException.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private static boolean hasSameStackTrace​(ReportedException.CauseTraceIterator causeTraceIterator, java.lang.Throwable e2)  
      boolean isOutOfMemory()
      Check if this is caused by an out of memory situation
      boolean isSame​(ReportedException e)
      Checks if this exception is considered the same as an other exception.
      private static java.lang.String makeCollectionNice​(java.util.Collection<?> value)  
      boolean mayHaveConcurrentSource()
      Check if this exception may be caused by a threading issue.
      private static java.lang.String niceThreadName​(java.lang.Thread thread)  
      void printReportDataTo​(java.io.PrintWriter out)
      Prints the captured data of this report to a PrintWriter.
      void printReportStackTo​(java.io.PrintWriter out)
      Prints the stack trace of this report to a PrintWriter.
      void printReportThreadsTo​(java.io.PrintWriter out)
      Prints the stack traces for other threads of this report to a PrintWriter.
      ReportedException put​(java.lang.String key, java.lang.Object value)
      Adds some debug values to this exception.
      ReportedException put​(java.lang.String key, java.util.function.Supplier<java.lang.Object> valueSupplier)
      Adds some debug values to this exception.
      void startSection​(java.lang.String sectionName)
      Starts a new debug data section.
      java.lang.String toString()  
      void warn()
      Displays a warning for this exception.
      • Methods inherited from class java.lang.Throwable

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

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

      • ReportedException

        public ReportedException​(java.lang.Throwable exception)
        Constructs a new ReportedException.
        Parameters:
        exception - the cause (which is saved for later retrieval by the Throwable.getCause() method)
        Since:
        14380
      • ReportedException

        public ReportedException​(java.lang.Throwable exception,
                                 java.lang.Thread caughtOnThread)
        Constructs a new ReportedException.
        Parameters:
        exception - the cause (which is saved for later retrieval by the Throwable.getCause() method)
        caughtOnThread - thread where the exception was caught
        Since:
        14380
    • Method Detail

      • warn

        public void warn()
        Displays a warning for this exception. The program can then continue normally. Does not block.
      • startSection

        public void startSection​(java.lang.String sectionName)
        Starts a new debug data section. This normally does not need to be called manually.
        Parameters:
        sectionName - The section name.
      • printReportDataTo

        public void printReportDataTo​(java.io.PrintWriter out)
        Prints the captured data of this report to a PrintWriter.
        Parameters:
        out - The writer to print to.
      • printReportStackTo

        public void printReportStackTo​(java.io.PrintWriter out)
        Prints the stack trace of this report to a PrintWriter.
        Parameters:
        out - The writer to print to.
      • printReportThreadsTo

        public void printReportThreadsTo​(java.io.PrintWriter out)
        Prints the stack traces for other threads of this report to a PrintWriter.
        Parameters:
        out - The writer to print to.
      • niceThreadName

        private static java.lang.String niceThreadName​(java.lang.Thread thread)
      • isSame

        public boolean isSame​(ReportedException e)
        Checks if this exception is considered the same as an other exception. This is the case if both have the same cause and message.
        Parameters:
        e - The exception to check against.
        Returns:
        true if they are considered the same.
      • put

        public ReportedException put​(java.lang.String key,
                                     java.lang.Object value)
        Adds some debug values to this exception. The value is converted to a string. Errors during conversion are handled.
        Parameters:
        key - The key to add this for. Does not need to be unique but it would be nice.
        value - The value.
        Returns:
        This exception for easy chaining.
      • put

        public ReportedException put​(java.lang.String key,
                                     java.util.function.Supplier<java.lang.Object> valueSupplier)
        Adds some debug values to this exception. This method automatically catches errors that occur during the production of the value.
        Parameters:
        key - The key to add this for. Does not need to be unique but it would be nice.
        valueSupplier - A supplier that is called once to get the value.
        Returns:
        This exception for easy chaining.
        Since:
        10586
      • makeCollectionNice

        private static java.lang.String makeCollectionNice​(java.util.Collection<?> value)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Throwable
      • mayHaveConcurrentSource

        public boolean mayHaveConcurrentSource()
        Check if this exception may be caused by a threading issue.
        Returns:
        true if it is.
        Since:
        10585
      • isOutOfMemory

        public boolean isOutOfMemory()
        Check if this is caused by an out of memory situation
        Returns:
        true if it is.
        Since:
        10819