Exception catch all statement

Hey guys. When using catch(...) to handle unexpected exceptions, is there a way to obtain a handle to the exception that was thrown so that I can call the "what()" function on it to get a description?

1
2
3
4
5
6
7
8
class exception {
public:
  exception () throw();
  exception (const exception&) throw();
  exception& operator= (const exception&) throw();
  virtual ~exception() throw();
  virtual const char* what() const throw();
}


Kind regards.
It sounds like you want to catch a std::exception& instead of all exceptions.
1
2
3
4
5
6
7
8
try
{
	// code that can throw
}
catch(std::exception& e)
{
	std::cout << e.what() << std::endl;
}

This will catch all instances of std::exception and instances of classes that inherit from std::exception.
Similar topic which you may fing useful:

http://www.cplusplus.com/forum/general/59693/
Topic archived. No new replies allowed.