From 5a260f5e574ad8e33cd5528c214b4a25b18e248e Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 14 Dec 2010 20:47:05 +0000 Subject: Better error messages. git-svn-id: http://svn.drobilla.net/lad/trunk/patchage@2685 a436a847-0d15-0410-975c-d299462d15a1 --- src/PatchageEvent.cpp | 24 ++++++++++++++---------- src/PortID.hpp | 21 +++++++++++++++++++++ 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/src/PatchageEvent.cpp b/src/PatchageEvent.cpp index c408f59..3085585 100644 --- a/src/PatchageEvent.cpp +++ b/src/PatchageEvent.cpp @@ -52,7 +52,7 @@ PatchageEvent::execute(Patchage* patchage) patchage->canvas()->remove_item(module); module.reset(); } else { - Raul::error << "Unable to find client " << _str << " to remove" << endl; + Raul::error << "Unable to find client `" << _str << "' to remove" << endl; } free(_str); @@ -76,9 +76,9 @@ PatchageEvent::execute(Patchage* patchage) if (port) patchage->enqueue_resize(port->module().lock()); else - Raul::error << "Unable to create port view" << endl; + Raul::error << "Unable to create port view: " << _port_1 << endl; } else { - Raul::error << "Attempt to create port with unknown type" << endl; + Raul::error << "Attempt to create port with unknown type: " << _port_1 << endl; } } else if (_type == PORT_DESTRUCTION) { @@ -102,7 +102,7 @@ PatchageEvent::execute(Patchage* patchage) } } else { - Raul::error << "Unable to find port to destroy" << endl; + Raul::error << "Unable to find port `" << _port_1 << "' to destroy" << endl; } } else if (_type == CONNECTION) { @@ -110,20 +110,24 @@ PatchageEvent::execute(Patchage* patchage) SharedPtr port_1 = patchage->canvas()->find_port(_port_1); SharedPtr port_2 = patchage->canvas()->find_port(_port_2); - if (port_1 && port_2) - patchage->canvas()->add_connection(port_1, port_2, port_1->color() + 0x22222200); + if (!port_1) + Raul::error << "Unable to find port `" << _port_1 << "' to connect" << endl; + else if (!port_2) + Raul::error << "Unable to find port `" << _port_2 << "' to connect" << endl; else - Raul::error << "Unable to find port to connect" << endl; + patchage->canvas()->add_connection(port_1, port_2, port_1->color() + 0x22222200); } else if (_type == DISCONNECTION) { SharedPtr port_1 = patchage->canvas()->find_port(_port_1); SharedPtr port_2 = patchage->canvas()->find_port(_port_2); - if (port_1 && port_2) - patchage->canvas()->remove_connection(port_1, port_2); + if (!port_1) + Raul::error << "Unable to find port `" << _port_1 << "' to disconnect" << endl; + else if (!port_2) + Raul::error << "Unable to find port `" << _port_2 << "' to disconnect" << endl; else - Raul::error << "Unable to find port to disconnect" << endl; + patchage->canvas()->remove_connection(port_1, port_2); } } diff --git a/src/PortID.hpp b/src/PortID.hpp index c221a0a..82a892a 100644 --- a/src/PortID.hpp +++ b/src/PortID.hpp @@ -20,6 +20,7 @@ #include "patchage-config.h" +#include #include #ifdef USE_LIBJACK #include @@ -60,5 +61,25 @@ struct PortID { } id; }; +static inline std::ostream& +operator<<(std::ostream& os, const PortID& id) +{ + switch (id.type) { + case PortID::NULL_PORT_ID: + return os << "(null)"; + case PortID::JACK_ID: +#ifdef USE_LIBJACK + return os << "jack:" << id.id.jack_id; +#endif + break; + case PortID::ALSA_ADDR: +#ifdef HAVE_ALSA + return os << "alsa:" << (int)id.id.alsa_addr.client << ":" << (int)id.id.alsa_addr.port; +#endif + break; + } + assert(false); +} + #endif // PATCHAGE_PORTID_HPP -- cgit v1.2.1