Class DefaultUncaughtExceptionHandler
java.lang.Object
de.gurkenlabs.litiengine.DefaultUncaughtExceptionHandler
- All Implemented Interfaces:
Thread.UncaughtExceptionHandler
public class DefaultUncaughtExceptionHandler
extends Object
implements Thread.UncaughtExceptionHandler
Handles the uncaught exceptions that might occur while running a game or application with the
LITIENGINE.
It provides proper logging of the exception in a crash.txt file in the game's root
directory that can be further used to report the issue if it's a generic one.
Depending on the configuration, the default behavior might force the game to exit upon an unexpected exception which can be useful to detect problems in your game early.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultUncaughtExceptionHandler(boolean exitOnException) Initializes a new instance of theDefaultUncaughtExceptionHandlerclass.DefaultUncaughtExceptionHandler(boolean exitOnException, boolean dumpThreads) Initializes a new instance of theDefaultUncaughtExceptionHandlerclass. -
Method Summary
Modifier and TypeMethodDescriptionprotected static Stringdump()booleanvoiddumpThreads(boolean dumpThreads) Set whether the generated crash report will contain an additional thread dumpbooleanIndicates whether this hander currently exits the game upon an unhandled exception.protected static StringvoidsetExitOnException(boolean exit) Set whether the game will exit upon an unhandled exception.voiduncaughtException(Thread t, Throwable e)
-
Constructor Details
-
DefaultUncaughtExceptionHandler
public DefaultUncaughtExceptionHandler(boolean exitOnException) Initializes a new instance of theDefaultUncaughtExceptionHandlerclass.- Parameters:
exitOnException- A flag indicating whether the game should exit when an unexpected exception occurs. The game will still exit if it encounters an Error.
-
DefaultUncaughtExceptionHandler
public DefaultUncaughtExceptionHandler(boolean exitOnException, boolean dumpThreads) Initializes a new instance of theDefaultUncaughtExceptionHandlerclass.- Parameters:
exitOnException- A flag indicating whether the game should exit when an unexpected exception occurs. The game will still exit if it encounters an ErrordumpThreads- A flag indicating whether the crash report should contain an additional thread dump.
-
-
Method Details
-
uncaughtException
- Specified by:
uncaughtExceptionin interfaceThread.UncaughtExceptionHandler
-
exitOnException
public boolean exitOnException()Indicates whether this hander currently exits the game upon an unhandled exception.Note that this handler will still exit if it encounters an unhandled Error.
- Returns:
- True if the game will exit upon an unhandled exception; otherwise false.
-
dumpsThreads
public boolean dumpsThreads()- Returns:
- true if the generated crash report will contain a thread dump
-
setExitOnException
public void setExitOnException(boolean exit) Set whether the game will exit upon an unhandled exception.- Parameters:
exit- The flag that defines whether the game will exit upon an unhandled exception.
-
dumpThreads
public void dumpThreads(boolean dumpThreads) Set whether the generated crash report will contain an additional thread dump- Parameters:
dumpThreads- The flag that defines whether crash report will contain a thread dump.
-
dump
-
getSystemInfo
-