2

I have some code like this:

   void myMethod(){
      try{
        someMethod();
      }
      catch(std::exception e){
        std::cout<<"std::exception"<<std::endl;
      }
      catch(...){
        std::cout<<"..."<<std::endl;
      }
  }

The thing is, that when someMethod throws an exception is printing always

"..."

. Also, the method someMethod isn't written by me, and I don't know what kind of exceptions could throw (no documentation).

My question is, how can I know what kind of exception (its class type) has been thrown when I'm in the catch(...) block?

Sometimes, my software enters inside that catch(...) and I want to know why is catching a exception to save that situation.

Any ideas?

tpgalan
  • 196
  • 1
  • 14
  • 1
    I would start with getting [The current exception](http://en.cppreference.com/w/cpp/error/current_exception) – Mgetz May 13 '14 at 19:45

1 Answers1

2

There is no way to determine the exception type (although you can assign it to a std::exception_ptr (c++11), which does not provide type information, neither).