Improve exception handling when loading chunks

Fixes #85
This commit is contained in:
Blue (Lukas Rieger) 2020-09-12 16:42:55 +02:00
parent c5ba4b1fea
commit 6e02ef7a78
1 changed files with 10 additions and 4 deletions

View File

@ -207,7 +207,7 @@ public class MCAWorld implements World {
}
}
private Chunk loadChunkOrEmpty(Vector2i chunkPos, int tries, long tryInterval) throws InterruptedException {
private Chunk loadChunkOrEmpty(Vector2i chunkPos, int tries, long tryInterval) {
Exception loadException = null;
for (int i = 0; i < tries; i++) {
try {
@ -217,7 +217,12 @@ public class MCAWorld implements World {
loadException = e;
if (tryInterval > 0 && i+1 < tries) {
Thread.sleep(tryInterval);
try {
Thread.sleep(tryInterval);
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
break;
}
}
}
}
@ -263,8 +268,9 @@ public class MCAWorld implements World {
} else {
throw new IOException("Invalid data tag: " + (tag == null ? "null" : tag.getClass().getName()));
}
} catch (RuntimeException | IOException e) {
throw new IOException("Exception trying to load chunk (" + chunkPos + ")", e);
} catch (RuntimeException e) {
throw new IOException(e);
}
}