🎉 Celebrating 25 Years of GameDev.net! 🎉

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!

Exception propagation

Started by
0 comments, last by WitchLord 19 years, 1 month ago
If I have a c++ class I have registered with AS and in a call to a method of the object used in a script my method throws an exception, is there anyway to propagate that up to the script engine and report it as a script error? Thanks, Scott
[size=1]'Behold! It is not over unknown seas but back over well-known years that your quest must go; back to the bright strange things of infancy and the quick sun-drenched glimpses of magic that old scenes brought to wide young eyes.'
Advertisement
There is currently no automatic treatment of C++ exceptions. You'll need to write a wrapper for the class method that catches the exception and raises a script exception instead.

Example:

void MyWrapper(obj *o){  try  {    o->DoSomething();  }  catch( E& e )  {    asIScriptContext *ctx = asGetActiveContext();    if( ctx ) ctx->SetException("An exception occured");  }}


AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement