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;
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 );