Original Post
Hi, Andreas
Is there a particular reason why Angelscript uses return codes instead of exception propagation?
It gives me a lot of headache recently. For example:
asIScriptFunction *setfunc = classType->GetMethodByDecl("void getProperty(int value)");
This one will return a null pointer cause of a typo in a passed declaration param. Ok, let's skip pointer check.
Then a code follows
context->Prepare(setfunc); //returns asNO_FUNCTION
context->SetObject(&scriptClassObj);
context->SetArgObject(0, &arg );
context->SetArgDWord(0, 22);//return asCONTEXT_NOT_PREPARED
context->Execute();
And it's fine here. We had some serious problems inside, but nothing crashed, nothing reported. The code is just
executed without a proper result.
So, either I have to check every pointer for null / return code for good, or to write wrappers for every AS class to handle this in a proper way.
Both ways are crap, require a lot of work and the code gets bloated.
And all I actually need is
catch(ASException& e)
{
//abort/report/whatever
}
Why not?
Is there a particular reason why Angelscript uses return codes instead of exception propagation?
It gives me a lot of headache recently. For example:
asIScriptFunction *setfunc = classType->GetMethodByDecl("void getProperty(int value)");
This one will return a null pointer cause of a typo in a passed declaration param. Ok, let's skip pointer check.
Then a code follows
context->Prepare(setfunc); //returns asNO_FUNCTION
context->SetObject(&scriptClassObj);
context->SetArgObject(0, &arg );
context->SetArgDWord(0, 22);//return asCONTEXT_NOT_PREPARED
context->Execute();
And it's fine here. We had some serious problems inside, but nothing crashed, nothing reported. The code is just
executed without a proper result.
So, either I have to check every pointer for null / return code for good, or to write wrappers for every AS class to handle this in a proper way.
Both ways are crap, require a lot of work and the code gets bloated.
And all I actually need is
catch(ASException& e)
{
//abort/report/whatever
}
Why not?