v0.2.3b: corrected error handling implementation for thread in InterlevelScene

This commit is contained in:
Evan Debenham 2015-01-07 18:51:47 -05:00
parent acbbbc1686
commit 88712f0654

View File

@ -17,7 +17,6 @@
*/ */
package com.shatteredpixel.shatteredpixeldungeon.scenes; package com.shatteredpixel.shatteredpixeldungeon.scenes;
import android.os.Build;
import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.Statistics; 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.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion; import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndError; import com.shatteredpixel.shatteredpixeldungeon.windows.WndError;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndStory; import com.shatteredpixel.shatteredpixeldungeon.windows.WndStory;
import com.watabou.noosa.BitmapText; import com.watabou.noosa.BitmapText;
@ -76,7 +74,7 @@ public class InterlevelScene extends PixelScene {
private BitmapText message; private BitmapText message;
private Thread thread; private Thread thread;
private String error = null; private Exception error = null;
@Override @Override
public void create() { public void create() {
@ -188,16 +186,12 @@ public class InterlevelScene extends PixelScene {
Sample.INSTANCE.load( Assets.SND_BOSS ); Sample.INSTANCE.load( Assets.SND_BOSS );
} }
} catch (FileNotFoundException e) { } catch (Exception e) {
error = ERR_FILE_NOT_FOUND; error = e;
} catch (IOException e ) {
error = ERR_IO;
} }
if (phase == Phase.STATIC && error == null) { if (phase == Phase.STATIC && error == null) {
phase = Phase.FADE_OUT; phase = Phase.FADE_OUT;
timeLeft = TIME_TO_FADE; timeLeft = TIME_TO_FADE;
@ -240,7 +234,13 @@ public class InterlevelScene extends PixelScene {
case STATIC: case STATIC:
if (error != null) { 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() { public void onBackPressed() {
super.onBackPressed(); super.onBackPressed();
Game.switchScene( StartScene.class ); Game.switchScene( StartScene.class );