Class ReportedException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
org.openstreetmap.josm.tools.bugreport.ReportedException
- All Implemented Interfaces:
Serializable
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate final classIterates over the causes for this exception.private static classprivate static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Map<Thread,StackTraceElement[]> We capture all stack traces on exception creation.private final Threadprivate static final intHow many entries of a collection to include in the bug report.private Stringprivate final LinkedList<ReportedException.Section>private static final long -
Constructor Summary
ConstructorsConstructorDescriptionReportedException(Throwable exception) Constructs a newReportedException.ReportedException(Throwable exception, Thread caughtOnThread) Constructs a newReportedException. -
Method Summary
Modifier and TypeMethodDescriptionprivate static booleanhasSameStackTrace(ReportedException.CauseTraceIterator causeTraceIterator, Throwable e2) booleanCheck if this is caused by an out of memory situationbooleanChecks if this exception is considered the same as an other exception.booleanCheck if this is caused by the name of a file which cannot be represented in the character set Java uses for file names.private static StringmakeCollectionNice(Collection<?> value) booleanCheck if this exception may be caused by a threading issue.private static StringniceThreadName(Thread thread) voidPrints the captured data of this report to aPrintWriter.voidPrints the stack trace of this report to aPrintWriter.voidPrints the stack traces for other threads of this report to aPrintWriter.Adds some debug values to this exception.Adds some debug values to this exception.voidstartSection(String sectionName) Starts a new debug data section.toString()voidwarn()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
-
Field Details
-
MAX_COLLECTION_ENTRIES
How many entries of a collection to include in the bug report.- See Also:
-
serialVersionUID
- See Also:
-
allStackTraces
We capture all stack traces on exception creation. This allows us to trace synchronization problems better. We cannot be really sure what happened but we at least see which threads -
sections
-
caughtOnThread
-
methodWarningFrom
-
-
Constructor Details
-
ReportedException
Constructs a newReportedException.- Parameters:
exception- the cause (which is saved for later retrieval by theThrowable.getCause()method)- Since:
- 14380
-
ReportedException
Constructs a newReportedException.- Parameters:
exception- the cause (which is saved for later retrieval by theThrowable.getCause()method)caughtOnThread- thread where the exception was caught- Since:
- 14380
-
-
Method Details
-
warn
Displays a warning for this exception. The program can then continue normally. Does not block. -
startSection
Starts a new debug data section. This normally does not need to be called manually.- Parameters:
sectionName- The section name.
-
printReportDataTo
Prints the captured data of this report to aPrintWriter.- Parameters:
out- The writer to print to.
-
printReportStackTo
Prints the stack trace of this report to aPrintWriter.- Parameters:
out- The writer to print to.
-
printReportThreadsTo
Prints the stack traces for other threads of this report to aPrintWriter.- Parameters:
out- The writer to print to.
-
niceThreadName
-
isSame
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:
trueif they are considered the same.
-
hasSameStackTrace
private static boolean hasSameStackTrace(ReportedException.CauseTraceIterator causeTraceIterator, Throwable e2) -
put
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
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
-
toString
-
mayHaveConcurrentSource
Check if this exception may be caused by a threading issue.- Returns:
trueif it is.- Since:
- 10585
-
isOutOfMemory
Check if this is caused by an out of memory situation- Returns:
trueif it is.- Since:
- 10819
-
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:
trueif it is.- Since:
- 19637
-