on exceptions that make game crash, show dialog with the real cause (close #51)
This commit is contained in:
parent
3ddda20b64
commit
7daafd612e
|
@ -40,6 +40,8 @@ public class Container extends AppGameContainer {
|
||||||
/** SlickException causing game failure. */
|
/** SlickException causing game failure. */
|
||||||
protected SlickException e = null;
|
protected SlickException e = null;
|
||||||
|
|
||||||
|
private Exception anyException = null;
|
||||||
|
|
||||||
public static Container instance;
|
public static Container instance;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -63,14 +65,16 @@ public class Container extends AppGameContainer {
|
||||||
while (running())
|
while (running())
|
||||||
gameLoop();
|
gameLoop();
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
e.printStackTrace();
|
anyException = e;
|
||||||
} finally {
|
} finally {
|
||||||
// destroy the game container
|
// destroy the game container
|
||||||
close_sub();
|
close_sub();
|
||||||
destroy();
|
destroy();
|
||||||
|
|
||||||
// report any critical errors
|
if (anyException != null) {
|
||||||
if (e != null) {
|
ErrorHandler.error("Something bad happend while playing", anyException, true);
|
||||||
|
anyException = null;
|
||||||
|
} else if (e != null) {
|
||||||
ErrorHandler.error(null, e, true);
|
ErrorHandler.error(null, e, true);
|
||||||
e = null;
|
e = null;
|
||||||
}
|
}
|
||||||
|
@ -112,7 +116,9 @@ public class Container extends AppGameContainer {
|
||||||
Options.saveOptions();
|
Options.saveOptions();
|
||||||
|
|
||||||
// reset cursor
|
// reset cursor
|
||||||
UI.getCursor().reset();
|
if (UI.getCursor() != null) {
|
||||||
|
UI.getCursor().reset();
|
||||||
|
}
|
||||||
|
|
||||||
// destroy images
|
// destroy images
|
||||||
InternalTextureLoader.get().clear();
|
InternalTextureLoader.get().clear();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user