Sign in to follow this  
Deyja

Exceptions

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this