diff runner/main.cpp @ 21:9a4e410bda7a

* Add --force option, and throw/catch exceptions for failure cases rather than exiting directly
author Chris Cannam
date Tue, 07 Jul 2009 10:34:27 +0000
parents 7d87bf308509
children 4ab7c925f7ac
line wrap: on
line diff
--- a/runner/main.cpp	Mon Jun 29 13:47:12 2009 +0000
+++ b/runner/main.cpp	Tue Jul 07 10:34:27 2009 +0000
@@ -143,7 +143,7 @@
     cerr << "Sonic Annotator v" << RUNNER_VERSION << endl;
     cerr << "A utility for batch feature extraction from audio files." << endl;
     cerr << "Mark Levy, Chris Sutton and Chris Cannam, Queen Mary, University of London." << endl;
-    cerr << "Copyright 2007-2008 Queen Mary, University of London." << endl;
+    cerr << "Copyright 2007-2009 Queen Mary, University of London." << endl;
     cerr << endl;
     cerr << "This program is free software.  You may redistribute copies of it under the" << endl;
     cerr << "terms of the GNU General Public License <http://www.gnu.org/licenses/gpl.html>." << endl;
@@ -246,6 +246,8 @@
     cerr << "                      for all supported audio files and take all of those as" << endl;
     cerr << "                      input instead." << endl;
     cerr << endl;
+    cerr << "  -f, --force         Continue with subsequent files following an error." << endl;
+    cerr << endl;
     cerr << "Housekeeping options:" << endl;
     cerr << endl;
     cerr << "  -l, --list          List all known transform ids to standard output." << endl;
@@ -360,6 +362,7 @@
     set<string> requestedTransformListFiles;
     set<string> requestedDefaultTransforms;
     set<string> requestedSummaryTypes;
+    bool force = false;
 //!!!    bool multiplex = false;
     bool recursive = false;
     bool list = false;
@@ -488,6 +491,9 @@
         } else if (arg == "-r" || arg == "--recursive") {
             recursive = true;
             continue;
+        } else if (arg == "-f" || arg == "--force") {
+            force = true;
+            continue;
         } else if (arg == "-l" || arg == "--list") {
             list = true;
             continue;
@@ -719,10 +725,11 @@
         std::cerr << "Extracting features for: \"" << i->toStdString() << "\"" << std::endl;
         try {
             manager.extractFeatures(*i);
-        } catch (FailedToOpenFile f) {
-            cerr << "ERROR: Failed to open output file for feature writer: "
-                 << f.what() << endl;
-            break;
+        } catch (std::exception e) {
+            cerr << "ERROR: Failed to process file \"" << i->toStdString()
+                 << "\": " << e.what() << endl;
+            if (force) continue;
+            else break;
         }
     }