clap

CLAP Audio Plugin API
Log | Files | Refs | README | LICENSE

commit 5182bbd5b2ce03db2c99cf571ba9032869c0513e
parent 8cc97718878abe0213e678ecdbc54fa7d4fb5f3e
Author: Alexandre BIQUE <bique.alexandre@gmail.com>
Date:   Wed, 19 May 2021 09:13:20 +0200

Better error message

Diffstat:
Mexamples/host/plugin-host.cc | 15+++++++++------
Mexamples/host/plugin-param.cc | 6+++++-
Mexamples/host/plugin-param.hh | 1+
3 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/examples/host/plugin-host.cc b/examples/host/plugin-host.cc @@ -693,8 +693,9 @@ void PluginHost::clapParamsAdjustBegin(clap_host *host, clap_id param_id) { if (param.isBeingAdjusted()) { std::ostringstream msg; - msg << "Plugin called clap_host_params.adjust_end() on param_id: " << param_id - << ", but this parameter is already marked as being adjusted"; + msg << "Plugin called clap_host_params.adjust_end() on "; + param.printShortInfo(msg); + msg << ", but this parameter is already marked as being adjusted"; throw std::logic_error(msg.str()); } @@ -709,8 +710,9 @@ void PluginHost::clapParamsAdjustEnd(clap_host *host, clap_id param_id) { if (!param.isBeingAdjusted()) { std::ostringstream msg; - msg << "Plugin called clap_host_params.adjust_end() on param_id: " << param_id - << ", but this parameter is not marked as being adjusted"; + msg << "Plugin called clap_host_params.adjust_end() on "; + param.printShortInfo(msg); + msg << ", but this parameter is not marked as being adjusted"; throw std::logic_error(msg.str()); } @@ -725,8 +727,9 @@ void PluginHost::clapParamsAdjust(clap_host *host, clap_id param_id, clap_param_ if (!param.isBeingAdjusted()) { std::ostringstream msg; - msg << "Plugin called clap_host_params.adjust() on param_id: " << param_id - << ", but this parameter is not marked as being adjusted"; + msg << "Plugin called clap_host_params.adjust() on "; + param.printShortInfo(msg); + msg << ", but this parameter is not marked as being adjusted"; throw std::logic_error(msg.str()); } diff --git a/examples/host/plugin-param.cc b/examples/host/plugin-param.cc @@ -63,8 +63,12 @@ bool PluginParam::isValueValid(const clap_param_value v) const { } } -void PluginParam::printInfo(std::ostream &os) const { +void PluginParam::printShortInfo(std::ostream &os) const { os << "id: " << info_.id << ", name: '" << info_.name << "', module: '" << info_.module << "'"; +} + +void PluginParam::printInfo(std::ostream &os) const { + printShortInfo(os); if (hasRange()) { os << ", min: "; diff --git a/examples/host/plugin-param.hh b/examples/host/plugin-param.hh @@ -25,6 +25,7 @@ public: bool isValueValid(const clap_param_value v) const; static bool areValuesEqual(clap_param_type type, clap_param_value v1, clap_param_value v2); + void printShortInfo(std::ostream &os) const; void printInfo(std::ostream &os) const; void printValue(const clap_param_value v, std::ostream &os) const;