From 56eae394cc37084eb92ac53c409ddfae09e6884e Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sat, 5 Sep 2015 13:16:26 +0200 Subject: [PATCH] provide details about session-creation failure. --- libs/ardour/ardour/session.h | 12 ++++++++++++ libs/ardour/session.cc | 12 ++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 2e223beba7..102cb4917e 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -22,6 +22,7 @@ #include "libardour-config.h" +#include #include #include #include @@ -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: diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index e1a41e8db7..b0fbe8f4d1 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -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);