Class DefaultUncaughtExceptionHandler

java.lang.Object
de.gurkenlabs.litiengine.DefaultUncaughtExceptionHandler
All Implemented Interfaces:
java.lang.Thread.UncaughtExceptionHandler

public class DefaultUncaughtExceptionHandler
extends java.lang.Object
implements java.lang.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:
ClientConfiguration.exitOnError()
  • Constructor Summary

    Constructors 
    ConstructorDescription
    DefaultUncaughtExceptionHandler​(boolean exitOnException)
    Initializes a new instance of the DefaultUncaughtExceptionHandler class.
  • Method Summary

    Modifier and TypeMethodDescription
    booleanexitOnException()
    Indicates whether this hander currently exits the game upon an unhandled exception.
    voidsetExitOnException​(boolean exit)
    Set whether the game will exit upon an unhandled exception.
    voiduncaughtException​(java.lang.Thread t, java.lang.Throwable e) 

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 error occurs.
  • Method Details

    • uncaughtException

      public void uncaughtException​(java.lang.Thread t, java.lang.Throwable e)
      Specified by:
      uncaughtException in interface java.lang.Thread.UncaughtExceptionHandler
    • exitOnException

      public boolean exitOnException()
      Indicates whether this hander currently exits the game upon an unhandled exception.
      Returns:
      True if the game will exit upon an unhandled exception; otherwise false.
    • 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.