f_alias: catch SGPropertyNode exceptions and generate runtime error
This commit is contained in:
parent
5a3f00bcac
commit
845196800b
1 changed files with 6 additions and 4 deletions
|
@ -306,10 +306,12 @@ static naRef f_alias(naContext c, naRef me, int argc, naRef* args)
|
||||||
NODEARG();
|
NODEARG();
|
||||||
SGPropertyNode* al;
|
SGPropertyNode* al;
|
||||||
naRef prop = naVec_get(argv, 0);
|
naRef prop = naVec_get(argv, 0);
|
||||||
if(naIsString(prop)) al = globals->get_props()->getNode(naStr_data(prop), true);
|
try {
|
||||||
else if(naIsGhost(prop)) al = *(SGPropertyNode_ptr*)naGhost_ptr(prop);
|
if(naIsString(prop)) al = globals->get_props()->getNode(naStr_data(prop), true);
|
||||||
else {
|
else if(naIsGhost(prop)) al = *(SGPropertyNode_ptr*)naGhost_ptr(prop);
|
||||||
naRuntimeError(c, "props.alias() with bad argument");
|
else throw string("props.alias() with bad argument");
|
||||||
|
} catch (const string& err) {
|
||||||
|
naRuntimeError(c, (char *)err.c_str());
|
||||||
return naNil();
|
return naNil();
|
||||||
}
|
}
|
||||||
return naNum((*node)->alias(al));
|
return naNum((*node)->alias(al));
|
||||||
|
|
Loading…
Add table
Reference in a new issue