summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2010-12-14 20:47:05 +0000
committerDavid Robillard <d@drobilla.net>2010-12-14 20:47:05 +0000
commit5a260f5e574ad8e33cd5528c214b4a25b18e248e (patch)
tree1b02ea3f4e50677ff9cf6086ffc8062f9cab7279
parentd9a54049e99f6c3963e1f48e04b9a7adcd81899b (diff)
downloadpatchage-5a260f5e574ad8e33cd5528c214b4a25b18e248e.tar.gz
patchage-5a260f5e574ad8e33cd5528c214b4a25b18e248e.tar.bz2
patchage-5a260f5e574ad8e33cd5528c214b4a25b18e248e.zip
Better error messages.
git-svn-id: http://svn.drobilla.net/lad/trunk/patchage@2685 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--src/PatchageEvent.cpp24
-rw-r--r--src/PortID.hpp21
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<PatchagePort> port_1 = patchage->canvas()->find_port(_port_1);
SharedPtr<PatchagePort> 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<PatchagePort> port_1 = patchage->canvas()->find_port(_port_1);
SharedPtr<PatchagePort> 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 <iostream>
#include <cstring>
#ifdef USE_LIBJACK
#include <jack/jack.h>
@@ -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