/////////////////////////////////////////////////////////////////////////////// // GetErrorString : Get Script error string LPCTSTR CScriptObject::GetErrorString() { m_szError[0] = 0; if (m_pScript != NULL) { try{ IScriptErrorPtr pError = m_pScript->GetError(); if (pError != NULL) { _bstr_t desc = _bstr_t("Error: ") + pError->GetDescription() + _bstr_t(", "); desc += pError->GetText() + _bstr_t("; in line "); desc += _bstr_t(pError->GetLine()); int count = __min(desc.length(), ERROR_DESC_LEN); // string may be truncated... _tcsncpy_s(m_szError, (LPCTSTR) desc, count); m_szError[count] = 0; pError->Clear(); } } catch(_com_error& e) { (void)(e); TRACE( (LPSTR)e.Description() ); TRACE( (LPSTR)"\n" ); } } return m_szError; }
// GetErrorNumber : Get Script error number LPCTSTR CScriptObject::GetErrorNumber() { m_szErrorNumber[0] = 0; if (m_pScript != NULL) { try{ IScriptErrorPtr pError = m_pScript->GetError(); if (pError != NULL) { _bstr_t num = _bstr_t(pError->GetNumber()); int count = __min(num.length(), ERROR_NUM_LEN); // string may be truncated... _tcsncpy(m_szErrorNumber, (LPCTSTR) num, count); m_szErrorNumber[count] = 0; //pError->Clear(); } } catch(_com_error& e) { TRACE( (LPTSTR)e.Description() ); TRACE( (LPTSTR)"\n" ); } } return m_szErrorNumber; }
// GetErrorDescription : Get Script error description LPCTSTR CScriptObject::GetErrorDescription() { m_szErrorDescription[0] = 0; if (m_pScript != NULL) { try{ IScriptErrorPtr pError = m_pScript->GetError(); if (pError != NULL) { _bstr_t desc = _bstr_t("ScriptError: ") + pError->GetDescription() + _bstr_t("."); int count = __min(desc.length(), ERROR_DESC_LEN); // string may be truncated... _tcsncpy(m_szErrorDescription, (LPCTSTR) desc, count); m_szErrorDescription[count] = 0; //pError->Clear(); } } catch(_com_error& e) { TRACE( (LPTSTR)e.Description() ); TRACE( (LPTSTR)"\n" ); } } return m_szErrorDescription; }
// GetErrorHelpFile : Get Script error help file LPCTSTR CScriptObject::GetErrorHelpFile() { m_szErrorHelpFile[0] = 0; if (m_pScript != NULL) { try{ IScriptErrorPtr pError = m_pScript->GetError(); if (pError != NULL) { _bstr_t helpfile = _bstr_t(pError->GetHelpFile()); int count = __min(helpfile.length(), ERROR_HELPFILE_LEN); // string may be truncated... _tcsncpy(m_szErrorHelpFile, (LPCTSTR) helpfile, count); m_szErrorHelpFile[count] = 0; //pError->Clear(); } } catch(_com_error& e) { TRACE( (LPTSTR)e.Description() ); TRACE( (LPTSTR)"\n" ); } } return m_szErrorHelpFile; }
// GetErrorDescription : Get Script error description void CScriptObject::ClearError() { if (m_pScript != NULL) { try{ IScriptErrorPtr pError = m_pScript->GetError(); if (pError != NULL) { pError->Clear(); } } catch(_com_error& e) { TRACE( (LPTSTR)e.Description() ); TRACE( (LPTSTR)"\n" ); } } }