🎉 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!

Exceptions

Started by
1 comment, last by Deyja 17 years, 8 months ago
This should be a pretty simple question, and it's something I can't test properly because it's rather hard to step through angelscript execution in the VC debugger and actually know WTF is what. I have a bound global function, lets call it 'bar'. The question is simple: What happens if a script calls bar, and bar throws an exception? The ideal behavior would be as if each call to a bound function had the code

try {
  call(...);
}
catch (...) 
{
  OMFG_ABORT();
}
wrapped around it. Am I going to have to write wrapper functions to add this behavior myself?
Advertisement
I have been thinking about this myself, but never dared to dwell on it too much. Exceptions are another point of potential incompatibility between platforms/compilers, as each compiler handles exceptions in its own way.

I agree that the ideal would be for AngelScript to catch any exception and convert it into a script exception instead (with the potential memory leak of anything not cleaned up by the application, including the exception object). But what kind of complexity would this add to AngelScript? I'm not sure.

As it is now, you'll probably be able to catch the exception at Execute() or ExecuteString() call, but there would be a lot of memory leaks as AngelScript wouldn't be able to clean up anything on the callstack.

I think I'll do it like this. Add an optional try/catch statement around calls into the C++ application, that way they can be turned on/off at compile time as the developer chooses.

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

Keep in mind, all I want to do is abort. I don't care much about handling the error or perpetuating a different kind of exception. All I want to do is keep that exception from trouncing through your VM causing all sorts of horrible damage.

This topic is closed to new replies.

Advertisement