RACING121 RACING121 - 2 years ago 86
Java Question

How to show dialog when lwjgl game crashes (java)

I am using LWJGL to make my new game.

Quick Question:

When my game crashes with something like this:

Exception in thread "main" java.lang.NullPointerException
at engineTester.MainGameLoop.main(
C:\Users\Kojo Ofori\AppData\Local\NetBeans\Cache\8.1\executor-snippets\run.xml:53: Java returned: 1

How do I get it to print it in dialog so that when someone runs it and it crashes they will be able to see it as a dialog that is has crashed

Hope it made sense

Answer Source

You can use try ...catch and catch the exception (in a baseclass / superclass), send the user an error code that he can report and log a more detailed error. Depending on your configuration:

    try {
        /* game is playing() */
    catch (MyGameException gameException) {        
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download