mixoexception.cpp

来自「miXo is a buzz machine (www.buzzmachines」· C++ 代码 · 共 38 行

CPP
38
字号
//$Id: MiXoException.cpp,v 1.1 2001-05-08 17:08:21+02 mimo Exp mimo $
// MidiException.cpp: implementation of the CMidiException class.
//
//////////////////////////////////////////////////////////////////////

#include <sstream>
#include "MiXoException.h"
#include "stdafx.h"
CMiXoException::CMiXoException(unsigned u,const char *f,const char *l)  throw()
:exception(),scMessage(),id(u) 
{ 
	stringstream stmTemp;
	stmTemp << GetLocalError(u);
	stmTemp << " in File:" << f << ", Line:" << l << ends;
	scMessage=stmTemp.str();
};


string CMiXoException::GetSystemError() const
{
	void far *lpMsgBuf;		//(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM)
	
	::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
		NULL,::GetLastError(),MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),
		(LPSTR)&lpMsgBuf,0,NULL);
	string strTheMsg;
	strTheMsg=reinterpret_cast<char far*>(lpMsgBuf);
	LocalFree( lpMsgBuf );
	return strTheMsg;
}
string CMiXoException::GetLocalError(unsigned u) const
{
	stringstream stmTemp;
	stmTemp << "MiXo-Error Code: " << u << " " << GetSystemError() << " TODO Load Error Codes from Resource" << endl;
	string str=stmTemp.str();
	return str;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?