From b4e6a2e80738bb80723a8d0c14b1ae62035c5332 Mon Sep 17 00:00:00 2001 From: max Date: Wed, 22 Jul 2020 23:51:00 +0200 Subject: [PATCH] Better error messages --- src/LibPDEngine.cpp | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/LibPDEngine.cpp b/src/LibPDEngine.cpp index 4c838e3..7f60b2b 100644 --- a/src/LibPDEngine.cpp +++ b/src/LibPDEngine.cpp @@ -227,8 +227,31 @@ void LibPDEngine::receiveLights(const char* s) { } } else { - // print out on command line - std::cout << "libpd prototype unrecognizes message: " << std::string(s) << std::endl; + bool utility_is_valid = true; + int utility_idx = -1; + try { + utility_idx = _utility_map.at(atoms[0]); // map::at throws an out-of-range + } + catch (const std::out_of_range& oor) { + std::cout << "prototype libpd engine Pd console message: " << std::string(s) << std::endl; + utility_is_valid = false; + //display("Warning:"+atoms[1]+" not found!"); + // print out on command line + } + if(utility_is_valid) + { + switch (utility_idx) + { + case 1: + std::cout << "prototype libpd engine Pd error message: " << std::string(s) << std::endl; + break; + + default: + break; + } + } + + } } @@ -269,7 +292,8 @@ const std::map LibPDEngine::_switchLight_map{ }; const std::map LibPDEngine::_utility_map{ - { "display", 0 } + { "display", 0 }, + { "error:", 1 } };