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 Details

    • DefaultUncaughtExceptionHandler

      public DefaultUncaughtExceptionHandler(boolean exitOnException)
      Initializes a new instance of the DefaultUncaughtExceptionHandler class.
      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 the DefaultUncaughtExceptionHandler class.
      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
      dumpThreads - A flag indicating whether the crash report should contain an additional thread dump.
  • Method Details

    • uncaughtException

      public void uncaughtException(Thread t, Throwable e)
      Specified by:
      uncaughtException in interface Thread.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

      protected static String dump()
    • getSystemInfo

      protected static String getSystemInfo()