Class ReportedException

java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
org.openstreetmap.josm.tools.bugreport.ReportedException
All Implemented Interfaces:
Serializable

public class ReportedException extends 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:
  • Field Details

  • Constructor Details

    • ReportedException

      public ReportedException(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(Throwable exception, 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 Details

    • warn

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

      public void startSection(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(PrintWriter out)
      Prints the captured data of this report to a PrintWriter.
      Parameters:
      out - The writer to print to.
    • printReportStackTo

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

      public void printReportThreadsTo(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 String niceThreadName(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.
    • hasSameStackTrace

      private static boolean hasSameStackTrace(ReportedException.CauseTraceIterator causeTraceIterator, Throwable e2)
    • put

      public ReportedException put(String key, 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(String key, Supplier<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 String makeCollectionNice(Collection<?> value)
    • toString

      public String toString()
      Overrides:
      toString in class 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
    • isUnmappableFileName

      public boolean isUnmappableFileName()
      Check if this is caused by the name of a file which cannot be represented in the character set Java uses for file names. Java takes that character set from the locale, so this happens when JOSM runs in the C/POSIX locale, or with a locale which is not installed: file names are then ASCII only, and opening a folder which holds a non-ASCII name fails. See #14596.
      Returns:
      true if it is.
      Since:
      19637