Mercurial > touhou
diff pytouhou/ui/music.pyx @ 602:c84227022765
Don’t crash when a sound file isn’t present in the resources.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sat, 25 Oct 2014 20:02:56 +0200 |
parents | e15672733c93 |
children | 4ce3ef053a25 |
line wrap: on
line diff
--- a/pytouhou/ui/music.pyx +++ b/pytouhou/ui/music.pyx @@ -85,11 +85,11 @@ cdef class SFXPlayer(MusicPlayer): cdef Chunk get_sound(self, name): cdef Chunk chunk if name not in self.sounds: - wave_file = self.loader.get_file(name) try: + wave_file = self.loader.get_file(name) chunk = load_chunk(wave_file) - except sdl.SDLError as error: - logger.warn(u'Sound “%s” not found: %s', name, error) + except (KeyError, sdl.SDLError) as error: + logger.warn('Sound “%s” not found: %s', name, error) chunk = None else: chunk.set_volume(self.volume)