|
From: Yoda-JM <yo...@us...> - 2010-08-15 14:52:05
|
Module: performous
Branch: joinmenu
Commit: 6d10efce3f07f9867852e53fd73257b419f9e1c8
Author: Lasse Karkkainen <tro...@tr...>
Date: Mon Jun 21 08:20:05 2010 +0300
More error handling for song loader (avoiding uncaught exceptions)
---
game/songs.cc | 16 ++++++++++------
1 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/game/songs.cc b/game/songs.cc
index 1bdb005..19e802d 100644
--- a/game/songs.cc
+++ b/game/songs.cc
@@ -42,12 +42,16 @@ void Songs::reload_internal() {
Profiler prof("Song loading took");
Paths paths = getPathsConfig("system/path_songs");
for (Paths::iterator it = paths.begin(); m_loading && it != paths.end(); ++it) {
- if (!fs::is_directory(*it)) { m_debug << ">>> Not scanning: " << *it << " (no such directory)" << std::endl; continue; }
- m_debug << ">>> Scanning " << *it << std::endl;
- size_t count = m_songs.size();
- reload_internal(*it);
- size_t diff = m_songs.size() - count;
- if (diff > 0 && m_loading) m_debug << diff << " songs loaded" << std::endl;
+ try {
+ if (!fs::is_directory(*it)) { m_debug << ">>> Not scanning: " << *it << " (no such directory)" << std::endl; continue; }
+ m_debug << ">>> Scanning " << *it << std::endl;
+ size_t count = m_songs.size();
+ reload_internal(*it);
+ size_t diff = m_songs.size() - count;
+ if (diff > 0 && m_loading) m_debug << diff << " songs loaded" << std::endl;
+ } catch (std::exception& e) {
+ m_debug << ">>> Error scanning " << *it << ": " << e.what() << std::endl;
+ }
}
prof("total");
if (m_loading) dumpSongs_internal(); // Dump the songlist to file (if requested)
|