Browse Source

Better error messages

tags/v1.3.0
max 4 years ago
parent
commit
b4e6a2e807
1 changed files with 27 additions and 3 deletions
  1. +27
    -3
      src/LibPDEngine.cpp

+ 27
- 3
src/LibPDEngine.cpp View File

@@ -227,8 +227,31 @@ void LibPDEngine::receiveLights(const char* s) {
} }
} }
else { 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<std::string, int> LibPDEngine::_switchLight_map{
}; };


const std::map<std::string, int> LibPDEngine::_utility_map{ const std::map<std::string, int> LibPDEngine::_utility_map{
{ "display", 0 }
{ "display", 0 },
{ "error:", 1 }
}; };






Loading…
Cancel
Save