コード例 #1
0
ファイル: CppSQLite3.cpp プロジェクト: xu1hua/SquareClear
CppSQLite3Exception::CppSQLite3Exception(const int nErrNode,
	const char *szErrMess,
	bool bDeleteMess)
{
	mnErrCode = nErrNode;
	mpszErrMessage = sqlite3_mprintf("%s[%d]: %s",
		ErrorCodeAsString(nErrNode),
		mnErrCode,
		szErrMess ? szErrMess : "");
	if (bDeleteMess && szErrMess)
	{
		sqlite3_free(mpszErrMessage);
	}
}
コード例 #2
0
/*!
 *	Standard constructor. Creates a new SQLiteException object and assigns values to
 *	its member variables from the parameter inputs.
 *	\param kiErrCode The integer error code specifying what kind of error occurred.
 *	\param szErrMsg A string containing a human-readable message detailing the error.
 *	\param bDeleteMsg If true, free the message after construction completes, else
 *	take ownership of the error string.
 */
archvision::sqlite::SQLiteException::SQLiteException(const int kiErrCode,
													 const archvision::core::string::TStringArg &kstrErrMsgArg,
													 bool bDeleteMsg/* = true */)
													 : m_iErrorCode(kiErrCode)
{
	archvision::core::string::TString strErrMsg(kstrErrMsgArg);
	char *szErrMsg = strErrMsg.getCopyA();
	char *szFullErrMsg = new char[256];
	sprintf(szFullErrMsg, "%s[%d]: %s",
			ErrorCodeAsString(kiErrCode).getA(),
			kiErrCode,
			szErrMsg ? szErrMsg : ""		/* If string is not null, print it */
		   );
	m_pstrErrorMsg = new archvision::core::string::TString(szFullErrMsg);
	if (bDeleteMsg && szErrMsg) {
		free(szErrMsg);
	} else {
		free(m_pstrErrorMsg);
		m_pstrErrorMsg = new archvision::core::string::TString(szErrMsg);
	}
}