CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10

Threaded View

  1. #1
    Join Date
    Sep 1999
    Posts
    102

    YATC (Yet Another Try Catch) (problem)

    Hi all,

    I have this code:
    Code:
    //CDsp.h file:
    
    class CDsp {
    public:
        class Error: public runtime_error
        {
        public:
    
            Error ();
            Error (const string& msg);
    
        };
    //rest of the class CDsp
    }
    /////////////////////////////////
    //CDsp.cpp file:
    
    CDsp::Error::Error (const string& msg)
            :runtime_error (msg)
    { }
    
    
    CDsp::Error::Error ()
            :runtime_error ("ptu: error")
    {}
    ///////////////////////////////////
    //in main:
    int main()
    {
    //code
    
    try {
           foo(); //throws exception type CDsp:Error
        }
        catch(CDsp::Error &err)
        {
          cout<<err.what()<<endl;
         // cout<<"bla"<<endl; //catch(...)
        }
    
    //code
    }
    /////////////////////////////////////////
    The thing is, that the program never enters the
    catch close, all though foo() is throwing an exception - could any one point to what am I doing wrong?
    It behaves the same with catch(...)

    Thanks in advance

    Dani.

    [Gabriel: edit: added [code ] tags]
    Last edited by Gabriel Fleseriu; January 28th, 2003 at 08:24 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured