Indeed. It appears that this would work just fine without relying on C++11.
This feature is definitely something that I'll add to the library as soon as possible.
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
Indeed. It appears that this would work just fine without relying on C++11.
This feature is definitely something that I'll add to the library as soon as possible.
I've implemented the exception translation callback in revision 2481.
void TranslateException(asIScriptContext *ctx, void* /*userParam*/)
{
try
{
// Retrow the original exception so we can catch it again
throw;
}
catch( std::exception &e )
{
// Tell the VM the type of exception that occurred
ctx->SetException(e.what());
}
catch(...)
{
// The callback must not allow any exception to be thrown, but it is not necessary
// to explicitly set an exception string if the default exception string is sufficient
}
}
// Register the callback with the engine
engine->SetTranslateAppExceptionCallback(asFUNCTION(TranslateException), 0, asCALL_CDECL);
I decided to have the callback registered with the engine rather than the context, as Boost113 had suggested in his implementation. I figured the callback is related to the registered functions, and not the VM that is calling them.