wiki:FDORfc37

Version 3 (modified by leaf, 15 years ago) ( diff )

--

FDO RFC 37 - Detailed Exception

This page contains an change request (RFC) for the FDO Open Source project. More FDO RFCs can be found on the RFCs page.

Status

RFC Template Version(1.0)
Submission Date June 08, 2009
Last Modified Leaf Li Timestamp
AuthorLeaf Li
RFC Statusdraft
Implementation Statusdraft
Proposed Milestone3.5.0.0
Assigned PSC guide(s)Greg Boone
Voting History
+1
+0
-0
-1

Motivation

To handle errors more accurately by providing more detailed exception information

Overview

FdoException is the root class for FDO exception handling. Currently FDO provides less than 10 exception classes derived from FdoException. So it is difficult for users to get the accurate error information so that they can take some actions according to exception type instead of just showing an error message. More exception classes will be provided in this RFC.

However, it is impossible for FDO exception classes to cover all exception type. For some FDO data sources such as Oracle and SQL Server, they already return their native error code to FDO provider when encountering errors. If FDO can return the native error code to users, users may be able to handle it properly. For exmaple,

try
{
    ......
}
catch (FdoException* e)
{
    FdoInt64 errorCode = e->GetNativeErrorCode();
    e->Release();
    // Take some measures according to native error code
    ......
}

Proposed Solution

The following methods will be added to class FdoException to return native error code. Providers will be updated to assign native error code when a FDO exception is created. If there is no native error code assigned, the default value is 0.

class FdoException : public FdoIDisposable
{
public:
    /// \brief
    /// Returns an instance of a FdoException using the specified arguments.
    /// 
    /// \param message 
    /// Input the error message
    /// \param nativeErrorCode 
    /// Input the native error code, which is returned by FDO data source.
    /// 
    /// \return
    /// Returns the FdoException object
    /// 
    FDO_API_COMMON static FdoException* Create(FdoString* message, FdoInt64 nativeErrorCode);

    /// \brief
    /// Returns an instance of a FdoException using the specified arguments.
    /// 
    /// \param message 
    /// Input the error message
    /// \param cause
    /// Input the cause of the error.
    /// \param nativeErrorCode 
    /// Input the native error code, which is returned by FDO data source.
    /// 
    /// \return
    /// Returns the FdoException object
    /// 
    FDO_API_COMMON static FdoException* Create(FdoString* message, FdoException* cause, FdoInt64 nativeErrorCode);

    /// \brief
    /// Gets the native error code returned from FDO data source
    /// 
    /// \return
    /// Returns the native error code
    /// 
    FDO_API_COMMON virtual FdoInt64 GetNativeErrorCode();
}

The following exception classes will be added to FDO API. In the following class diagram, ones with white color are the existing classes and ones with light green color are the new ones. There are no any new methods added to those new exception classes. All of methods are inherited from FdoIException.

The description of new exception classes above are as follows.

Managed FDO API

Currently FDO Managed Interfaces provide OSGeo::FDO::Common::Exception only. So we will create managed classes for all of existing exception classes and new exception classes proposed in this RFC. OSGeo::FDO::Common::Exception will be updated in a similar manner to reflect the proposed changes in this RFC too.

Provider Implementation

Which providers will need to be modified to throw an accurate exception will depend on available development resources. I am fairly confident SQLite will be enhanced to support it. Adding support to SQL Server Spatial and ODBC should also be high on the priority list. Update for other providers are considered nice to have and will be implemented if resourcing and funding can be obtained.

Test Plan

Existing FDO Core and Provider level unit tests will be expanded to test the proposed enhancements defined above.

Funding/Resources

Autodesk to provide resources / funding.

Attachments (2)

Download all attachments as: .zip

Note: See TracWiki for help on using the wiki.