From 88712f0654a04800c34a9302795daf7dbf348ae9 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Wed, 7 Jan 2015 18:51:47 -0500 Subject: [PATCH] v0.2.3b: corrected error handling implementation for thread in InterlevelScene --- .../scenes/InterlevelScene.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/scenes/InterlevelScene.java b/src/com/shatteredpixel/shatteredpixeldungeon/scenes/InterlevelScene.java index fddf61b77..20602b8cc 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/scenes/InterlevelScene.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/scenes/InterlevelScene.java @@ -17,7 +17,6 @@ */ package com.shatteredpixel.shatteredpixeldungeon.scenes; -import android.os.Build; import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.Statistics; @@ -26,7 +25,6 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Generator; import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion; import com.shatteredpixel.shatteredpixeldungeon.levels.Level; -import com.shatteredpixel.shatteredpixeldungeon.ui.Window; import com.shatteredpixel.shatteredpixeldungeon.windows.WndError; import com.shatteredpixel.shatteredpixeldungeon.windows.WndStory; import com.watabou.noosa.BitmapText; @@ -76,7 +74,7 @@ public class InterlevelScene extends PixelScene { private BitmapText message; private Thread thread; - private String error = null; + private Exception error = null; @Override public void create() { @@ -188,16 +186,12 @@ public class InterlevelScene extends PixelScene { Sample.INSTANCE.load( Assets.SND_BOSS ); } - } catch (FileNotFoundException e) { + } catch (Exception e) { - error = ERR_FILE_NOT_FOUND; - - } catch (IOException e ) { - - error = ERR_IO; + error = e; } - + if (phase == Phase.STATIC && error == null) { phase = Phase.FADE_OUT; timeLeft = TIME_TO_FADE; @@ -240,7 +234,13 @@ public class InterlevelScene extends PixelScene { case STATIC: if (error != null) { - add( new WndError( error ) { + String errorMsg; + if (error instanceof FileNotFoundException) errorMsg = ERR_FILE_NOT_FOUND; + else if (error instanceof IOException) errorMsg = ERR_IO; + + else throw new RuntimeException("fatal error occured while moving between floors", error); + + add( new WndError( errorMsg ) { public void onBackPressed() { super.onBackPressed(); Game.switchScene( StartScene.class );