我想在catch(...){} 里面捕捉 错误的详细信息。如何修改catch(...){} 
估计是将...换成其他什么的吗?

解决方案 »

  1.   

    try
    {
        // Execute some code that might throw an exception.
    }
    catch( CException* e )
    {
        // Handle the exception here.
        // "e" contains information about the exception.
        e->Delete();
    }
      

  2.   

    我这里没有用mfc,CException 显然不成
    有 不使用mfc的吗?
      

  3.   

    try
    {
        // Execute some code that might throw an exception.
    }
    catch( exception& e )
    {
        // Handle the exception here.
        // "e" contains information about the exception.
        cout << "exception catched:" << e.what() << endl;
    }
      

  4.   

    yeyuboy(海绵) ,booklove(纳海行云),你们的大恩大德小弟永生难忘。
      

  5.   

    catch(char* sErrorMsg)
    {
    if (sError != sErrorMsg)
    strncpy(sError,sErrorMsg,128);
    }
    catch(_com_error &e)
    {
    PrintComErrorString(sError,e);
    }
    catch(...)
    {
    strcpy(sError,"未知错误!");
    }
      

  6.   

    catch原理float mydiv(int n1,int n2)
    {
        if(n2==0)
          throw "there is an error!"
    }
      

  7.   

    catch原理float mydiv(int n1,int n2)
    {
        if(n2==0)
          throw "there is an error!"
        else
          return n1*1.0/n2;}
    void test()
    {
       float f1;
       try
       {
         f1=mydiv(2,9)
       }
       catch( CString e)
       {
         AfxMessageBox(e);
       }
       catch(...)
       {
         AfxMessageBox("an uncatch error!");
       }
    }