Add support for std::exception and what()

This commit is contained in:
Jonathan Turner 2009-09-18 22:26:07 +00:00
parent 204d379176
commit b17c6b9748
2 changed files with 16 additions and 3 deletions

View File

@ -674,6 +674,7 @@ namespace chaiscript
m->add(fun(&to_string<bool>), "internal_to_string");
m->add(fun(&unknown_assign), "=");
m->add(fun(&throw_exception), "throw");
m->add(fun(&what), "what");
bootstrap_pod_type<double>("double", m);
bootstrap_pod_type<int>("int", m);

View File

@ -591,9 +591,21 @@ namespace chaiscript
try {
retval = eval_token(ss, node->children[0]);
}
catch (std::exception &) {
// nothing
std::cout << "DEBUG: std::exception caught" << std::endl;
catch (const Eval_Error &) {
throw;
}
catch (const std::exception &e) {
if (node->children.size() > 2) {
if (node->children[1]->text == "catch") {
if (node->children.size() > 3) {
ss.add_object(node->children[2]->text, Boxed_Value(boost::ref(e)));
retval = eval_token(ss, node->children[3]);
}
else {
retval = eval_token(ss, node->children[2]);
}
}
}
}
catch (Boxed_Value &bv) {
if (node->children.size() > 2) {