# HG changeset patch # User Emmanuel Gil Peyrot # Date 1346258068 -7200 # Node ID 70e2ed71b09c3f30b4f6f44a92efa01f690f77b6 # Parent 69ec72b990a475118d07495647e04f63ce7ee499 Add meaningful exceptions in format parsing. diff --git a/pytouhou/formats/__init__.py b/pytouhou/formats/__init__.py --- a/pytouhou/formats/__init__.py +++ b/pytouhou/formats/__init__.py @@ -3,3 +3,9 @@ This package provides modules to handle the various proprietary file formats used by Touhou games. """ + +class WrongFormatError(Exception): + pass + +class ChecksumError(Exception): + pass diff --git a/pytouhou/formats/anm0.py b/pytouhou/formats/anm0.py --- a/pytouhou/formats/anm0.py +++ b/pytouhou/formats/anm0.py @@ -23,6 +23,8 @@ Almost everything rendered in the game i from struct import pack, unpack from pytouhou.utils.helpers import read_string, get_logger +from pytouhou.formats import WrongFormatError + logger = get_logger(__name__) @@ -84,9 +86,8 @@ class ANM0(object): first_name_offset, unused, secondary_name_offset = unpack(' self._max_offset: - raise Exception #TODO + raise Exception('Music ends after the end of the file.') self._duration = None