These are chat archives for ChaiScript/ChaiScript

18th
Jul 2017
kila58 (Gage)
@kila58
Jul 18 2017 09:37
Is there any way to properly error handle a function once it's passed to c++? I noticed that unless you actually call a function within chai that contains an error it wont raise an exception so it's somewhat problematic for my event system.
Jason Turner
@lefticus
Jul 18 2017 13:58
I'm not aware of any situations where chaiscript does not throw an exception when an error occurs. Can you please provide a complete (separate, compilable) example that illustrates the problem?
kila58 (Gage)
@kila58
Jul 18 2017 15:23
#include "chaiscript/chaiscript.hpp"    

int main()
{
    chaiscript::ChaiScript chai;

    try
    {
        chai.eval_file("test.chai", chaiscript::exception_specification<const std::exception&, const chaiscript::Boxed_Value&>());
    }
    catch (const chaiscript::exception::eval_error& e)
    {
        printf(e.pretty_print().c_str());
    }
    catch (const std::exception& e)
    {
        printf(e.what());
    }
    catch (const chaiscript::Boxed_Value& e)
    {

    }
}
def move()
{
   test = 5;
}
kila58 (Gage)
@kila58
Jul 18 2017 15:30
I was almost sure this was by design though because when I called the function in the script it does catch the exception. But in my case I don't want to call the function within the script itself.