From 845196800bff0220090295b40af3d99c26061077 Mon Sep 17 00:00:00 2001 From: mfranz Date: Thu, 13 Nov 2008 23:47:45 +0000 Subject: [PATCH] f_alias: catch SGPropertyNode exceptions and generate runtime error --- src/Scripting/nasal-props.cxx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Scripting/nasal-props.cxx b/src/Scripting/nasal-props.cxx index 359eb9131..e6e542eae 100644 --- a/src/Scripting/nasal-props.cxx +++ b/src/Scripting/nasal-props.cxx @@ -306,10 +306,12 @@ static naRef f_alias(naContext c, naRef me, int argc, naRef* args) NODEARG(); SGPropertyNode* al; naRef prop = naVec_get(argv, 0); - if(naIsString(prop)) al = globals->get_props()->getNode(naStr_data(prop), true); - else if(naIsGhost(prop)) al = *(SGPropertyNode_ptr*)naGhost_ptr(prop); - else { - naRuntimeError(c, "props.alias() with bad argument"); + try { + if(naIsString(prop)) al = globals->get_props()->getNode(naStr_data(prop), true); + else if(naIsGhost(prop)) al = *(SGPropertyNode_ptr*)naGhost_ptr(prop); + else throw string("props.alias() with bad argument"); + } catch (const string& err) { + naRuntimeError(c, (char *)err.c_str()); return naNil(); } return naNum((*node)->alias(al));