home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / include / idsexc.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  3.7 KB  |  106 lines

  1. /********************************************************************************/
  2. /* File:   idsexc.hpp                                                           */
  3. /* Class:  exception classes                                                    */
  4. /*                                                                              */
  5. /*                                                                              */
  6. /********************************************************************************/
  7.  
  8. /***********************************************
  9.  
  10.     Licensed Materials - Property of IBM
  11.  
  12.     5622-880   5801-AAR
  13.  
  14.     (c) Copyright IBM Corp 1991, 1996.
  15.  
  16. ************************************************/
  17.  
  18. #ifndef _IDSEXC_HPP_
  19. #define _IDSEXC_HPP_
  20.  
  21. #include <ibase.hpp>
  22. #include <iexcbase.hpp>
  23. #include <idaerrno.hpp>
  24. #include <string.h>
  25. #include <istring.hpp>
  26.  
  27. // Preserved for compatability with release 1.0.
  28. // Emulates the DB2 1.2 sqlca structure.
  29. struct DA_sqlca
  30. {
  31.   long sqlcode; unsigned char sqlstate[5];
  32.   DA_sqlca( long anSQLCODE, char* anSQLSTATE ) : sqlcode(anSQLCODE)
  33.       { memcpy( sqlstate, anSQLSTATE, sizeof(sqlstate) ); }
  34. };
  35.  
  36.  
  37. #define IDACLASSDECLARE(child,parent) class _Export child : public parent {\
  38. public:\
  39.   child( const char*, \
  40.          unsigned long b = 0,\
  41.          Severity c = IException::unrecoverable,\
  42.          long anSQLCODE = 0,\
  43.          char* anSQLSTATE = 0);\
  44.   child( const child& ); \
  45.   virtual ~child();\
  46.   virtual const char* name() const;\
  47. }
  48.  
  49. // parent class for all data access exceptions:
  50. class _Export IDAException : public IException
  51. {
  52.   public:
  53.     IDAException( const char* a,
  54.                   unsigned long b = 0,
  55.                   Severity c = IException::unrecoverable,
  56.                   long anSQLCODE = 0,
  57.                   char* anSQLSTATE = 0 );
  58.     IDAException( const IDAException& );
  59.     virtual ~IDAException();
  60.     virtual const char* name() const;
  61.     Boolean errorProvided() const;
  62.     // these methods return null if ! errorProvided()
  63.     const char* errorState() const;
  64.     long errorCode() const;
  65.     IString errorAsString() const;
  66.     // for backward compatability only
  67.     struct DA_sqlca getSqlca() const;
  68.   protected:
  69.     long iSQLCODE;
  70.     IString iSQLSTATE;
  71.     IBoolean iErrorProvided;
  72. };
  73.  
  74.    IDACLASSDECLARE(IDAAdaptorException, IDAException);
  75.       IDACLASSDECLARE(IDAConnectFailed, IDAAdaptorException);
  76.       IDACLASSDECLARE(IDADisconnectError, IDAAdaptorException);
  77.       IDACLASSDECLARE(IDAConnectionInUse, IDAAdaptorException);
  78.       IDACLASSDECLARE(IDAConnectionNotOpen, IDAAdaptorException);
  79.  
  80.    IDACLASSDECLARE (IDALogonFailed, IDAException);
  81.    IDACLASSDECLARE (IDALogoffFailed, IDAException);
  82.  
  83.    IDACLASSDECLARE (IDAAccessError, IDAException);
  84.       IDACLASSDECLARE (IDADataObjectNotFound, IDAAccessError);
  85.       IDACLASSDECLARE (IDADataObjectInvalid, IDAAccessError);
  86.       IDACLASSDECLARE (IDADataObjectAlreadyExists, IDAAccessError);
  87.  
  88.    IDACLASSDECLARE (IDADataObjectAttributeError, IDAException);
  89.  
  90.  
  91. // For backward compatibility
  92. typedef IDAException               IDSAccessError;
  93. typedef IDAAdaptorException        IDatastoreAdaptorException;
  94. typedef IDAConnectFailed           IConnectFailed;
  95. typedef IDADisconnectError         IDisconnectError;
  96. typedef IDAConnectionInUse         IDatastoreConnectionInUse;
  97. typedef IDAConnectionNotOpen       IDatastoreConnectionNotOpen;
  98. typedef IDADataObjectNotFound      IDataObjectNotFound;
  99. typedef IDADataObjectAlreadyExists IDataObjectAlreadyExist;
  100. typedef IDALogonFailed             IDatastoreLogonFailed;
  101. typedef IDALogoffFailed            IDatastoreLogoffFailed;
  102. typedef IDAAccessError             IDatastoreAccessError;
  103. typedef IDADataObjectInvalid       IDataObjectInvalid;
  104.  
  105. #endif
  106.