//--------------------------------------------------------------------------- // TJSGetExceptionObject : retrieves TJS 'Exception' object //--------------------------------------------------------------------------- void TJSGetExceptionObject(tTJS *tjs, tTJSVariant *res, tTJSVariant &msg, tTJSVariant *trace/* trace is optional */) { if(!res) return; // not prcess // retrieve class "Exception" from global iTJSDispatch2 *global = tjs->GetGlobalNoAddRef(); tTJSVariant val; static tTJSString Exception_name(TJS_W("Exception")); tjs_error hr = global->PropGet(0, Exception_name.c_str(), Exception_name.GetHint(), &val, global); if(TJS_FAILED(hr)) TJS_eTJSError(TJSExceptionNotFound); // create an Exception object iTJSDispatch2 *excpobj; tTJSVariantClosure clo = val.AsObjectClosureNoAddRef(); tTJSVariant *pmsg = &msg; hr = clo.CreateNew(0, NULL, NULL, &excpobj, 1, &pmsg, clo.ObjThis); if(TJS_FAILED(hr)) TJS_eTJSError(TJSExceptionNotFound); if(trace) { static tTJSString trace_name(TJS_W("trace")); excpobj->PropSet(TJS_MEMBERENSURE, trace_name.c_str(), trace_name.GetHint(), trace, excpobj); } *res = tTJSVariant(excpobj, excpobj); excpobj->Release(); }