Rogue Wave banner
Previous fileTop of DocumentContentsIndexNext file

RWDBStatus


RWDBStatus RWDBFuture

Data Type and Member Function Indexes
(exclusive of constructors and destructors)

Synopsis

#include <rw/db/status.h>

RWDBStatus status = myDbase.status();    //status of object
RWDBStatus status = myDbase.createTable("tableName",myschema);
                                         //status of function

Description

RWDBStatus encapsulates the error state of an object or operation. A valid object or a successful operation is represented by RWDBStatus::ok. An RWDBStatus that is not valid contains an error code, an error message, and often some supplemental information provided by a database vendor's API.

Each RWDBStatus object contains a callback routine that can be changed by an application. If an RWDBStatus changes state to anything but RWDBStatus::ok, the installed handler is called with self as an argument.

In the DBTools.h++ error model, the use of exceptions is optional, and is under the application's control. The raise() method of RWDBStatus throws an exception of type RWExternalErr. Thus, an application may choose to enforce a terminating or nonterminating model of error handling by installing an appropriate error handler.

When DBTools.h++ objects are produced by other objects, the produced object's status is copied from the producer. Consequently, an application can control error handling at any level it chooses. A handler installed in the RWDBManager is propagated to every DBTools.h++ object in the application; one installed in an RWDBDatabase is propagated to each object produced by that RWDBDatabase, and so on down to the level of individual objects.

RWDBStatus is designed around the Interface/Implementation paradigm. An RWDBStatus instance is an interface to a reference-counted implementation; copy constructors and assignment operators produce additional references to a shared implementation.

Example

An application that requires C++ exceptions throughout would proceed this way:

Public Typedefs and Enums

This is the signature of an RWDBStatus error handling routine:

At this writing, these are the possible RWDBStatus error codes:

enum ErrorCode 
{
   ok = 0,           // No error
   noMem,            // Out of memory
   notInitialized,   // Object never initialized
   typeConversion,   // Type conversion error
   dbNotFound,       // Database not registered
   serverError,      // Error reported by server
   serverMessage,    // Message from server
   vendorLib,        // Error from vendor's library
   notConnected,     // Lost connection
   endOfFetch,       // End of fetch
   invalidUsage,     // Invalid usage of object
   columnNotFound,   // Column does not exist
   invalidPosition,  // Invalid positioning within object,
                     //  i.e., bounds error
   notSupported,     // Unsupported feature
   nullReference,    // Null reference parameter
   notFound,         // Database object not found
   missing,          // Required piece of information is 
                     // missing
   noMultiReaders,   // This object cannot support multiple
                     //  readers
   noDeleter,        // This object cannot support deletions
   noInserter,       // This object cannot support insertions
   noUpdater,        // This object cannot support updates
   noReader,         // This object cannot support updates
   noIndex,          // This object cannot support indices
   noDrop,           // This object cannot be dropped
   wrongConnection,  // Incorrect connection was supplied
   noPrivilege,      // This object cannot support privileges
   noCursor,         // This object cannot support cursors
   cantOpen          // Unable to open
   applicationError  // Errors produced at the application 
                     // level
   notReady          // For future use
}

Public Constructors

RWDBStatus();
RWDBStatus(const RWDBStatus& status);

Public Member Operator

RWDBStatus& 
operator=(const RWDBStatus& status);

Public Member Functions

ErrorCode
errorCode() const;
ErrorHandler
errorHandler() const;
RWBoolean
isTerminal() const;
RWBoolean
isValid() const;
RWCString
message() const;
void
raise() const;
void
setErrorHandler(RWDBStatus::ErrorHandler handler);

Public Member Functions: Vendor-Specific

The following methods return database-specific error information. If a status object has an error code of serverError, serverMessage, or vendorLib, these methods may provide additional information, as documented in the DBTools.h++ access library guides. Otherwise, these methods return 0 or the empty string, as appropriate.

long
vendorError1() const;
long
vendorError2() const;
RWCString
vendorMessage1() const;
RWCString
vendorMessage2() const;


Previous fileTop of DocumentContentsIndexNext file

©Copyright 1999, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.