# HG changeset patch # User Emmanuel Gil Peyrot # Date 1414260176 -7200 # Node ID c842270227652c41e1249e7070e5b3d45dea72ee # Parent 016f6b937893cfd1eea42d4a0a76a9227b24fea5 Don’t crash when a sound file isn’t present in the resources. diff --git a/pytouhou/ui/music.pyx b/pytouhou/ui/music.pyx --- 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)