Table of Contents

Exception Handling

exceptions.jpgIBPP reports errors exclusively through C++ exceptions. Return values of methods calls are never used to return success or failure. All exceptions classes thrown by IBPP derive from the std::exception class and re-implement their virtual method const char* what(), making it easy to handle those either globally of through dedicated catch handlers.

Exceptions Classes

IBPP::Exception

class Exception : public std::exception
{
public:
    virtual const char* Origin() const throw() = 0;
    virtual const char* what() const throw() = 0;
    virtual ~Exception() throw();
};

This is the base class of all exceptions thrown by IBPP. It directly derives from std::exception and only adds one Origin() method to the standard interface.

Origin() is a string, specific to IBPP, which identifies which part of the IBPP source code thrown the exception. This is mostly useful for debugging and of low interest to the end-users of application programs using IBPP.

IBPP::LogicException

class LogicException : public Exception
{
public:
    virtual ~LogicException() throw();
};

IBPP::LogicException brings nothing new to the interface of IBPP::Exception. It is only meant to distinguish, by name, between exceptions which are inherent to IBPP itself from those (IBPP::SQLException) which are thrown when the database engine reports operational errors.

IBPP::SQLException

class SQLException : public Exception
{
public:
    virtual int SqlCode() const throw() = 0;
    virtual int EngineCode() const throw() = 0;

    virtual ~SQLException() throw();
};

IBPP::SQLException reports errors returned by the database engine itself. IBPP::SQLException adds two specific members to the generic IBPP::Exception interface.

SqlCode() returns the eventual standard SQL error code. EngineCode() returns the internal engine error code.

You should read some more documentation on Firebird to get all the details and the differences between those two values and how you can make use of them.

IBPP::WrongType

class WrongType : public LogicException
{
public:
    virtual ~WrongType() throw();
};

IBPP::WrongType is a specialization of IBPP::LogicException which brings nothing new to the interface of LogicException. It is only meant to distinguish (by the exception name) some specific kind of LogicException.