CPortManagerException

Name

CPortManagerException -- Report errors conditions in port manager transactions

Synopsis


#include <config.h<
#include <histotypes.h<
#include <CPortManagerException.h<


         
 class CPortManagerException {

  CPortManagerException(std::string host, Reason why, std::string doing);

  virtual const const char* ReasonText();
  virtual const Int_t ReasonCode();
  static string ReasonCodeToText(int code);
}

ostream& operator<< ( ostream& f , const CPortManagerException& e );

Description

CPortManagerException is an exception that can be thrown by the port manager class CPortManager see the man page for that class). Since it is derived from CException, it can be caught as a generic error. In addition to the base class members, the class supports insertion into an output stream.

Public member functions

CPortManagerException(std::string host, Reason why, std::string doing);

Constructs the exception. host is the host that the object was connected to, or attempted to connect to when the error was detected. whyIs the reason for the exception. See "Types and public data" below for more information about the possible values the Reason type can take. doing provides context information that describes what the object was attempting to do when the error was detected.

virtual const const char* ReasonText();

Returns comprehensive human readable text that describes the reason this operation failed.

virtual const Int_t ReasonCode();

Returns the reason code. The reason code is just the Reason cast to an integer.

static string ReasonCodeToText(int code);

Converts a reason code into a text string that describes the reason.

ostream& operator<< ( ostream& f , const CPortManagerException& e );

Formats the exception object e and writes it to the output stream f. A reference to the output stream is returned allowing the normal sorts of cascading of the operator<< function.

Types and public data

Reason is an enumerated type that describes the actual error condition that was detected:

NoPorts

When attempting to allocate a service port, thee daemon reported that all available service ports in the block it is managing are in use.

NotLocal

You are attempting to allocate a port on a remote system. Service ports can only be allocated by programs running on the same system as the port manager daemon.

ConnectionFailed

An attempt to connect to the daemon failed.

EXAMPLES

The example below catches an exception. If the exception was thrown because of a Connection failure. it is just printed to cerr. Otherwise, The reason text is printed along with a message idicating that a port allocation failed.

Example 1. Catching a CPortManagerException


…
try {
…
}
catch (CPortManagerException& e) {
  int why = e.ReasonCode();
  if((CPortManagerException::Reason)why ==
                  CPortManagerException::ConnectionFailed) {
     cerr << e << endl;
  }
  else {
     cerr << "Port Allocation Failed: " << e.ReasonText() << endl;
  }
}

…
                
            

SEE ALSO

portAllocator(3tcl), CPortManager(3daq), DaqPortManager(1tcl) CException(3tcl)