Hello,
The documentation states that the application can throw C++ exceptions and the AS VM will automatically catch them, fail the current script context and return back to the application.
However, this assumes that the application is a C++ application - I am currently working on Swift bindings for AngelScript, and Swift cannot throw nor catch C++ exceptions. My current implementation uses the AS C interface with cdecl
and cdeclObjfirst
calling conventions, which cannot throw exceptions either.
I need to be able to throw exceptions from the application to AS for null-safety reasons: right now if Swift receives a null
handle as a function parameter, I have no choice but to crash the whole program. That is because with the C calling convention, I have no way to fail the current script context execution without returning anything (it's a Swift safety constraint and a calling convention limitation).
So I wondered, if I were to use the generic calling convention instead of cdecl
, would I be able to “throw” an exception instead of returning a value? I don't see any method to set exceptions on asIScriptGeneric
so I assume not, but I figured I could ask here.
Thanks!