exception man page on SunOS

Man page or keyword search:  
man Server   20652 pages
apropos Keyword Search (all sections)
Output format
SunOS logo
[printable version]

exception(3C++)			       -		       exception(3C++)

Standard C++ Library Copyright 1998, Rogue Wave Software, Inc.

NAME
       exception

	- A class that supports logic and runtime errors.

SYNOPSIS
#include <exception>
class exception;

DESCRIPTION
       The  class  exception  defines  the base class for the types of objects
       thrown as exceptions  by	 Standard  C++	Library	 components  and  some
       expressions.  This  class is used to report errors detected during pro‐
       gram execution. Users can also use these exceptions to report errors in
       their own programs.

INTERFACE
       class exception {

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

class logic_error : public exception {
  public:
    explicit logic_error (const string& what_arg);
 };

class domain_error : public logic_error {
  public:
    explicit domain_error (const string& what_arg);
 };

class invalid_argument : public logic_error {
  public:
    explicit invalid_argument (const string& what_arg);
 };

class length_error : public logic_error {
  public:
    explicit length_error (const string& what_arg);
 };

class out_of_range : public logic_error {
  public:
    explicit out_of_range (const string& what_arg);
 };

class runtime_error : public exception {
  public:
    explicit runtime_error (const string& what_arg);
 };

class range_error : public runtime_error {
  public:
    explicit range_error (const string& what_arg);
 };

class overflow_error : public runtime_error {
  public:
    explicit overflow_error (const string& what_arg);
 };

class underflow_error : public runtime_error {
  public:
    explicit underflow_error (const string& what_arg);
 };

CONSTRUCTORS
exception()
throw();

   Constructs an object of class exception.

exception(const exception&)
throw();

   Copies an exception object.

DESTRUCTORS
       virtual
       ~exception()
       throw();

   Destroys an object of class exception.

OPERATORS
       exception&
       operator=(const exception&)
       throw();

   Copies an exception object.

MEMBER FUNCTIONS
       virtual const char*
       what()const
       throw();

   Returns an implementation-defined, null-terminated byte string representing
   a human-readable message describing the exception. The  message  may	 be  a
   null-terminated  multibyte string, suitable for conversion and display as a
   wstring.

CONSTRUCTORS FOR DERIVED CLASSES
       logic_error::logic_error(const string& what_arg);

   Constructs an object of class logic_error.

domain_error::domain_error(const string& what_arg);

   Constructs an object of class domain_error.

invalid_argument::invalid_argument(const string& what_arg);

   Constructs an object of class invalid_argument.

length_error::length_error(const string& what_arg);

   Constructs an object of class length_error.

out_of_range::out_of_range(const string& what_arg);

   Constructs an object of class out_of_range.

runtime_error::runtime_error(const string& what_arg);

   Constructs an object of class runtime_error.

range_error::range_error(const string& what_arg);

   Constructs an object of class range_error.

overflow_error::overflow_error(const string& what_arg);

   Constructs an object of class overflow_error.

underflow_error::underflow_error(
		   const string& what_arg);

   Constructs an object of class underflow_error.

EXAMPLE
  //
  // except.cpp
  //
  #include <iostream>
  #include <stdexcept>
 using namespace std;

 static void f() { throw runtime_error("a runtime error"); }

 int main ()
  {
     //
     // By wrapping the body of main in a try-catch block
     // we can be assured that we'll catch all exceptions
     // in the exception hierarchy. You can simply catch
     // exception as is done below, or you can catch each
     // of the exceptions in which you have an interest.
     //
    try
     {
	f();
     }
    catch (const exception& e)
     {
	cout << "Got an exception: " << e.what() << endl;
     }
    return 0;
  }

Rogue Wave Software		  02 Apr 1998		       exception(3C++)
[top]

List of man pages available for SunOS

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net