provide details about session-creation failure.
authorRobin Gareus <robin@gareus.org>
Sat, 5 Sep 2015 11:16:26 +0000 (13:16 +0200)
committerRobin Gareus <robin@gareus.org>
Sat, 5 Sep 2015 13:44:41 +0000 (15:44 +0200)
libs/ardour/ardour/session.h
libs/ardour/session.cc

index 2e223beba7b1a4d6c7ec975b8ff28c914111f627..102cb4917ee7ea1930b0f38bde0367f472cfa47e 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "libardour-config.h"
 
+#include <exception>
 #include <list>
 #include <map>
 #include <set>
@@ -139,6 +140,17 @@ class WindowsVSTPlugin;
 
 extern void setup_enum_writer ();
 
+class LIBARDOUR_API SessionException: public std::exception {
+public:
+       explicit SessionException(const std::string msg) : _message(msg) {}
+       virtual ~SessionException() throw() {}
+
+       virtual const char* what() const throw() { return _message.c_str(); }
+
+private:
+       std::string _message;
+};
+
 class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionList, public SessionEventManager
 {
   public:
index e1a41e8db7f574769b473d3c70978fabc703f4c5..b0fbe8f4d18c8cbe031de86a104597f28b5a631a 100644 (file)
@@ -315,12 +315,12 @@ Session::Session (AudioEngine &eng,
 #endif
                if (ensure_engine (sr)) {
                        destroy ();
-                       throw failed_constructor ();
+                       throw SessionException (_("Cannot connect to audio/midi engine"));
                }
 
                if (create (mix_template, bus_profile)) {
                        destroy ();
-                       throw failed_constructor ();
+                       throw SessionException (_("Session initialization failed"));
                }
 
                /* if a mix template was provided, then ::create() will
@@ -336,7 +336,7 @@ Session::Session (AudioEngine &eng,
 
                if (!mix_template.empty()) { 
                        if (load_state (_current_snapshot_name)) {
-                               throw failed_constructor ();
+                               throw SessionException (_("Failed to load template/snapshot state"));
                        }
                        store_recent_templates (mix_template);
                }
@@ -347,7 +347,7 @@ Session::Session (AudioEngine &eng,
        } else {
 
                if (load_state (_current_snapshot_name)) {
-                       throw failed_constructor ();
+                       throw SessionException (_("Failed to load state"));
                }
        
                /* try to get sample rate from XML state so that we
@@ -364,13 +364,13 @@ Session::Session (AudioEngine &eng,
 
                if (ensure_engine (sr)) {
                        destroy ();
-                       throw failed_constructor ();
+                       throw SessionException (_("Cannot connect to audio/midi engine"));
                }
        }
 
        if (post_engine_init ()) {
                destroy ();
-               throw failed_constructor ();
+               throw SessionException (_("Cannot configure audio/midi engine with session parameters"));
        }
 
        store_recent_sessions (_name, _path);