From a5612a1fa593c1086af899c8d3bf4d025be36245 Mon Sep 17 00:00:00 2001 From: Aaron Griffith Date: Sun, 6 Mar 2011 15:48:48 -0500 Subject: [PATCH] moved corrupt chunk handling to get_lvldata so it applies to all chunk loading brought up in Issue #286: https://github.com/brownan/Minecraft-Overviewer/issues/286 --- chunk.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/chunk.py b/chunk.py index 8b74041..e8ab061 100644 --- a/chunk.py +++ b/chunk.py @@ -49,8 +49,13 @@ image def get_lvldata(filename, x, y): """Takes a filename and chunkcoords and returns the Level struct, which contains all the level info""" - - d = nbt.load_from_region(filename, x, y) + + try: + d = nbt.load_from_region(filename, x, y) + except Exception, e: + logging.warning("Error opening chunk (%i, %i) in %s. It may be corrupt. %s", x, y, filename, e) + raise ChunkCorrupt(str(e)) + if not d: raise NoSuchChunk(x,y) return d[1]['Level'] @@ -253,9 +258,6 @@ class ChunkRenderer(object): except NoSuchChunk, e: #logging.debug("Skipping non-existant chunk") raise - except Exception, e: - logging.warning("Error opening chunk file %s. It may be corrupt. %s", self.regionfile, e) - raise ChunkCorrupt(str(e)) return self._level level = property(_load_level)