From 7daafd612e8dd132795208a8b9c7fdca2da5b2e3 Mon Sep 17 00:00:00 2001 From: yugecin Date: Sun, 20 Nov 2016 13:45:05 +0100 Subject: [PATCH] on exceptions that make game crash, show dialog with the real cause (close #51) --- src/itdelatrisu/opsu/Container.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/itdelatrisu/opsu/Container.java b/src/itdelatrisu/opsu/Container.java index e5d6c234..f462a3e7 100644 --- a/src/itdelatrisu/opsu/Container.java +++ b/src/itdelatrisu/opsu/Container.java @@ -40,6 +40,8 @@ public class Container extends AppGameContainer { /** SlickException causing game failure. */ protected SlickException e = null; + private Exception anyException = null; + public static Container instance; /** @@ -63,14 +65,16 @@ public class Container extends AppGameContainer { while (running()) gameLoop(); } catch(Exception e) { - e.printStackTrace(); + anyException = e; } finally { // destroy the game container close_sub(); destroy(); - // report any critical errors - if (e != null) { + if (anyException != null) { + ErrorHandler.error("Something bad happend while playing", anyException, true); + anyException = null; + } else if (e != null) { ErrorHandler.error(null, e, true); e = null; } @@ -112,7 +116,9 @@ public class Container extends AppGameContainer { Options.saveOptions(); // reset cursor - UI.getCursor().reset(); + if (UI.getCursor() != null) { + UI.getCursor().reset(); + } // destroy images InternalTextureLoader.get().clear();