Name

bad_exception class — Wrong exception type

Synopsis

class bad_exception : public exception {
public:
  bad_exception(  ) throw(  );
  bad_exception(const bad_exception&) throw(  );
  bad_exception& operator=(const bad_exception&) throw(  );
  virtual const char* what(  ) const throw(  );
};

A bad_exception object is thrown from the unexpected function when unexpected throws an exception that is not listed in the exception specification that caused unexpected to be called. Most programs do not throw or catch bad_exception. You can list bad_exception in an exception specification if you want to handle this unusual situation differently.

See Chapter 5 and unexpected (in this section) for more details.

See Also

terminated function, unexpected function, throw keyword

Get C++ In a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.