我想實現類似於我的VS 2008的C++/MFC項目下面的內容:趕上拋出異常使用自定義字符串參數
class myClass()
{
public:
myClass()
{
//Do work... check for errors
if(var < 0)
{
//Error
TCHAR buff[1024];
_snwprintf_s(buff, SIZEOF(buff), L"ERROR: The value of var=%d", var);
throw buff;
}
}
};
__try
{
//Begin using class above
//The class member may be also defined on the global scale, thus
//the following exception trap may happen via SetUnhandledExceptionFilter
myClass mc;
}
__except(1)
{
//Process unhandled exception
//But how to trap the string passed in 'throw' above?
}
但我似乎無法趕上「串「我通過了throw
聲明。
試圖抓住一個const char *參數: http://stackoverflow.com/questions/2410609/c-exception-parameter – Lovy