| … | … | @@ -23,6 +23,7 @@ |
| 23 | 23 | #include <opencog/atoms/atom_types/NameServer.h> |
| 24 | 24 | #include <opencog/atoms/base/Link.h> |
| 25 | 25 | #include <opencog/atoms/base/Node.h> |
| 26 | #include <opencog/atoms/parallel/TriggerLink.h> |
| 26 | 27 | #include <opencog/atoms/value/FloatValue.h> |
| 27 | 28 | #include <opencog/atomspace/AtomSpace.h> |
| 28 | 29 | #include <opencog/atomspace/version.h> |
| … | … | @@ -569,9 +570,19 @@ std::string JSCommands::interpret_command(AtomSpace* as, |
| 569 | 570 | // { "type": "NumberNode", "name": "2" }] }) |
| 570 | 571 | if (execu == act) |
| 571 | 572 | { |
| 572 | | ADD_ATOM; |
| 573 | | |
| 574 | | ValuePtr vp = h->execute(); |
| 573 | // try..catch is needed because the Atom might be a TriggerLink |
| 574 | // which will force execution, but then throw an exception with |
| 575 | // the result of execution in it. |
| 576 | ValuePtr vp; |
| 577 | try |
| 578 | { |
| 579 | ADD_ATOM; |
| 580 | vp = h->execute(); |
| 581 | } |
| 582 | catch (const ValueReturnException& ex) |
| 583 | { |
| 584 | vp = ex._value; |
| 585 | } |
| 575 | 586 | std::string result = js_mode ? Json::encode_value(vp) : Sexpr::encode_value(vp); |
| 576 | 587 | RETURNSTR(result); |
| 577 | 588 | } |