AngelScript
Loading...
Searching...
No Matches
doc_cpp_exceptions.h
1)
30{
31 try
32 {
33 // Retrow the original exception so we can catch it again
34 throw;
35 }
36 catch( std::exception &e )
37 {
38 // Tell the VM the type of exception that occurred
39 ctx->SetException(e.what());
40 }
41 catch(...)
42 {
43 // The callback must not allow any exception to be thrown, but it is not necessary
44 // to explicitly set an exception string if the default exception string is sufficient
45 }
46}
47
48// Register the callback with the engine
49engine->SetTranslateAppExceptionCallback(asFUNCTION(TranslateException), 0, asCALL_CDECL);
50\endcode
51
52\see \ref doc_addon_helpers "GetExceptionInfo" helper function
53
54\note The ability to catch exceptions can be turned off by compiling the library with the AS_NO_EXCEPTIONS defined. If this is done, the application should not register any functions that may throw exceptions, as the end result will be
55undefined should an exception occur.
56
57\section doc_cpp_exceptions_2 longjmp
58
59Some applications uses longjmp to do error handling. When performing a longjmp to a previously saved state, there is no chance for the code to do a cleanup of all that happened after the saved state. Because of that the application must not register functions that can perform a longjmp out from the function, as that can leave the virtual machine in an undefined state.
60
61*/
@ asCALL_CDECL
A cdecl function.
#define asFUNCTION(f)
Returns an asSFuncPtr representing the function specified by the name.