AngelScript Knows The Values From Division by zero
i'v stumble across bug or very random feature from AS it can divide by zero :D int a=0; int b=1; int t=b/a; print(t); [all execution stops at the int t=b/a , with no warnings or errors] int a=1; int b=1; int t=b/a; print(t); [this prints all good] print is simple function that users CScriptString AS 2.18.1 WIP i'm not sure if it's a mix of try catch, but i did't use any is there a way to inform user about division per zero, because this can lead to [user will search his code, why this code doesn't execute after this, and he won't understand why] is there a way to enable such warnings?
Crazy dude smoking D3D11, AngelScript, PhysX, 3D Sound, Network, DB, FBX, and some other weird things, doing that on Visual Studio 2010 + Visual Assist X on Overclocked CPU
The asIScriptContext::Execute method returns asEXECUTION_EXCEPTION in this case. You need to handle that to print the warning about the reason and location for the exception. For example:
Regards,
Andreas
// Execute the script and handle the return coder = ctx->Execute();if( r != asEXECUTION_FINISHED ){ if( r == asEXECUTION_EXCEPTION ) PrintException(ctx); else ... handle the other possibilities (suspend, abort, etc)}// A function to print information about script exceptionsvoid PrintException(asIScriptContext *ctx){ asIScriptEngine *engine = ctx->GetEngine(); int funcId = ctx->GetExceptionFunction(); const asIScriptFunction *function = engine->GetFunctionDescriptorById(funcId); printf("func: %s\n", function->GetDeclaration()); printf("modl: %s\n", function->GetModuleName()); printf("sect: %s\n", function->GetScriptSectionName()); printf("line: %d\n", ctx->GetExceptionLineNumber()); printf("desc: %s\n", ctx->GetExceptionString());}
Regards,
Andreas
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
Popular Topics
Advertisement
Recommended Tutorials
Advertisement