Enhanced Exception Types in FDO

8 messages Options
Embed this post
Permalink
Greg Boone

Enhanced Exception Types in FDO

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)

Hi All,

 

I am currently struggling with the topic of error handling and exceptions in FDO, FDO Providers and applications that use them. I would like to get some feedback from the community on how we could possibly resolve this issue in the next planned release of FDO (trunk).

 

Currently, the FDO API uses a throw/catch exception handling solution with the FdoException class being the root class for all exception types in the FDO architecture. The FDO API currently has  less than 10 derived exception classes to indicate the specific type of exception that has occurred in a provider, or application. The type of the exception object along with the exception message attached to the exception is the general extent of the error information that application developers can use to write provider/application specific error handling code. This lack of information makes it difficult for clients to get enough information concerning the error that occurred to take an appropriate action. Because of this limitation, applications are generally forced to catch only the base FdoException type, exit the routine gracefully, and show the error message to the user. 
 
Typically this mechanism really breaks down when dealing with database solutions such as Oracle, ODBC, MySQL, SQLite, etc.. where the underlying implementation provides a native error code to represent an error that has occurred. This native error code sometimes is accompanied by an error string or can be interpreted by the provider to generate an error message. However, for the client catching the error from the provider, interpreting the string is a difficult task. The client typically does not want to parse the string and generally has no knowledge of the native error that has occurred. 
 

So, how can we improve this mechanism and still allow developers to write generic applications against FDO that work with many types of providers?

 

One idea has been to extend the number of generic exception class types that FDO supports to support generic exceptions such as…

 

Constraint Exception:

 

    NullPropertyValue

    OutOfRangePropertyValue

    NotUniquePropertyvalue

    NotInListPropertyValue

 

Schema Exceptions:

 

    SchemaDoesNotExist

    SchemaAlreadyExists

    ClassDoesNotExist

    ClassAlreadyExists

    PropertyDoesNotExist

    PropertyAlreadyExists

 

Connection Exceptions:

 

    NotConnected

    WrongConnectionParameterValue

    InsufficientPrivaledges

 

Command Exceptions:

 

    SQLCommand

    InvalidSQLStatement

 

 

 

 

While this approach  would allow a certain level of flexibility in writing standardized FDO applications and its utilities, it still does not offer any real ability to access the underlying native error code in a generic manner, especially for RDBMS providers.

 

Here are some other quick ideas that I thought of:

 

1)      Add RDBMS specific exception types to the FDO API

2)      Add a GetNativeErrorCode method to FdoException that would return the error code returned by the underlying datastore/database

 

The first idea of adding RDBMS specific exception types may help a little, but may further complicate the try.. catch error handling strategy that applications are forced to implement. It also may limit the manner in which generic code can be written, and in the end still not be sufficient to meet all our clients requirements.

 

The GetNativeErrorCode thought is a good one, but by using it in an application, they would really have to know which provider returned that code and do some form of look-up to determine what it actually means. This would reduce the amount of generic provider agnostic code that applications can effectively write. I can see IsOracle() or IsPostGIS() calls creeping into applications and developers attempt to take advantage.

So, with these thoughts in mind, I would like to solicit feedback from the community to gather your thoughts and ideas on how this issue could be dealt with effectively. There has been a lot of provider development on Oracle/PostGIS/SQLite/MySQL/ODBC, etc, in the last number of years. What do you as provider developers think of the ideas expressed above? What error handling issues have you run up against that would have liked to have seen solved generically in the FDO API?  What ideas and thoughts do you have that may help me come to some conclusions on this topic and move forward?

 

Regards,

Greg





_______________________________________________
fdo-internals mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fdo-internals

image002.emz (18K) Download Attachment
oledata.mso (119K) Download Attachment
Jackie Ng

Re: Enhanced Exception Types in FDO

Reply Threaded More More options
Print post
Permalink
Hi Greg,

How about including the provider name as part of the exception?

eg. GetProvider() returns "OSGeo.SQLite" if exception thrown from SQLite provider, "OSGeo.MySQL" if thrown from MySQL, etc.

- Jackie

Greg Boone wrote:
The GetNativeErrorCode thought is a good one, but by using it in an application, they would really have to know which provider returned that code and do some form of look-up to determine what it actually means. This would reduce the amount of generic provider agnostic code that applications can effectively write. I can see IsOracle() or IsPostGIS() calls creeping into applications and developers attempt to take advantage.
Frank Warmerdam

Re: Enhanced Exception Types in FDO

Reply Threaded More More options
Print post
Permalink
In reply to this post by Greg Boone
Greg Boone wrote:
> Hi All,
>
>  
>
> I am currently struggling with the topic of error handling and
> exceptions in FDO, FDO Providers and applications that use them. I would
> like to get some feedback from the community on how we could possibly
> resolve this issue in the next planned release of FDO (trunk).

Greg,

I wonder if you could talk us through a couple examples where the current
system is inadequate.  I can see value in adding some additional exception
classes to support finer grained error handling.

I'm concerned that exposing native error codes and provider id's as part
of exceptions is giving up on genericity in the FDO API.  But if you can
illustrate cases where this is critical it could be ok.

 From the point of view of the GDAL provider, I have no need to provide
finer grained error information from GDAL itself.  GDAL has a very thin
set of native error codes, and essentially the error text (which is
formatted with potentially lots of detail) is the important cargo.

Of course, I have not done much application writing on FDO so it is hard
for me to know what things applications writers are having trouble handling.

Best regards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, [hidden email]
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent

_______________________________________________
fdo-internals mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fdo-internals
zspitzer

Re: Enhanced Exception Types in FDO

Reply Threaded More More options
Print post
Permalink
It would be nice if we had defined error codes ase well which
people could then google to find out more information

ie FDO-0001 FDO-0002 or FDO-NotUniquePropertyvalue

searching for info using generic error phrases is rather difficult

with regards to Franks question, if we look at say JDBC or ODBC
both return the native error code / message

what about returning the generated sql used as well?

one of the oft raised questions on the mapguide list is in regards
to the use of the IN operator

a good example is when you hit a unique index or constraint, assuming the
underlying database has nicely named constraints/indexes, the native
error message
includes the name of the constraint which can be self explanatory

z


On Tue, Jun 2, 2009 at 12:29 PM, Frank Warmerdam <[hidden email]> wrote:

> Greg Boone wrote:
>>
>> Hi All,
>>
>>
>> I am currently struggling with the topic of error handling and exceptions
>> in FDO, FDO Providers and applications that use them. I would like to get
>> some feedback from the community on how we could possibly resolve this issue
>> in the next planned release of FDO (trunk).
>
> Greg,
>
> I wonder if you could talk us through a couple examples where the current
> system is inadequate.  I can see value in adding some additional exception
> classes to support finer grained error handling.
>
> I'm concerned that exposing native error codes and provider id's as part
> of exceptions is giving up on genericity in the FDO API.  But if you can
> illustrate cases where this is critical it could be ok.
>
> From the point of view of the GDAL provider, I have no need to provide
> finer grained error information from GDAL itself.  GDAL has a very thin
> set of native error codes, and essentially the error text (which is
> formatted with potentially lots of detail) is the important cargo.
>
> Of course, I have not done much application writing on FDO so it is hard
> for me to know what things applications writers are having trouble handling.
>
> Best regards,
> --
> ---------------------------------------+--------------------------------------
> I set the clouds in motion - turn up   | Frank Warmerdam,
> [hidden email]
> light and sound - activate the windows | http://pobox.com/~warmerdam
> and watch the world go round - Rush    | Geospatial Programmer for Rent
>
> _______________________________________________
> fdo-internals mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/fdo-internals
>



--
Zac Spitzer -
http://zacster.blogspot.com
+61 405 847 168
_______________________________________________
fdo-internals mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fdo-internals
Philipp Kast

RE: Enhanced Exception Types in FDO

Reply Threaded More More options
Print post
Permalink
In reply to this post by Frank Warmerdam
Some javascript/style in this post has been disabled (why?)

Hi

 

I'm trying to provide an example where you need more information about an exception than just an exception with a text.

 

If you build an application on FDO that needs to handle exceptions you need information about the problem that actually caused the exception, means more than a text.

 

A general example: Your Application needs a column MY_NUMBER in every feature class where you store some information. When you want to write something in this column and the column does not exist, you want to add the column programmatically. But every provider is complaining with different text messages that this column does not exist.

Oracle throws ORA-00904: "MY_NUMBER": invalid identifier

SQLite throws no such column: MY_NUMBER

How are you going to handle this exception? There is no way doing it generally.

A solution would be that all FDO providers are throwing and exception ColumnDoesNotExist or a FdoException with an FDO error code, e. g. FDO-001 or whatever.

 

Another example with a data store specific error. You have code that wants to select data from a Oracle based feature class. If you don’t have spatial index defined on this table you will get an Oracle error. E. g. ORA-13226: interface not supported without a spatial index.

So if a program wants to handle this exception it has to know what happened, getting the error code 13226. You could add the spatial index again over ISQLCommand. This is an error that can only happen on a Oracle data store, therefore it is provider specific.

This example is specific to a certain FDO provider, namely Oracle. You need to handle this specific to Oracle Provider, so you need an provider specific native error code, ORA-13226.

 

Philipp

 

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Frank Warmerdam (External)
Sent: Tuesday, June 02, 2009 4:29 AM
To: FDO Internals Mail List
Subject: Re: [fdo-internals] Enhanced Exception Types in FDO

 

Greg Boone wrote:

> Hi All,

>

>

> I am currently struggling with the topic of error handling and

> exceptions in FDO, FDO Providers and applications that use them. I would

> like to get some feedback from the community on how we could possibly

> resolve this issue in the next planned release of FDO (trunk).

 

Greg,

 

I wonder if you could talk us through a couple examples where the current

system is inadequate.  I can see value in adding some additional exception

classes to support finer grained error handling.

 

I'm concerned that exposing native error codes and provider id's as part

of exceptions is giving up on genericity in the FDO API.  But if you can

illustrate cases where this is critical it could be ok.

 

 From the point of view of the GDAL provider, I have no need to provide

finer grained error information from GDAL itself.  GDAL has a very thin

set of native error codes, and essentially the error text (which is

formatted with potentially lots of detail) is the important cargo.

 

Of course, I have not done much application writing on FDO so it is hard

for me to know what things applications writers are having trouble handling.

 

Best regards,

--

---------------------------------------+--------------------------------------

I set the clouds in motion - turn up   | Frank Warmerdam, [hidden email]

light and sound - activate the windows | http://pobox.com/~warmerdam

and watch the world go round - Rush    | Geospatial Programmer for Rent

 

_______________________________________________

fdo-internals mailing list

[hidden email]

http://lists.osgeo.org/mailman/listinfo/fdo-internals


_______________________________________________
fdo-internals mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fdo-internals
Dan Stoica

RE: Enhanced Exception Types in FDO

Reply Threaded More More options
Print post
Permalink
In reply to this post by Greg Boone
Some javascript/style in this post has been disabled (why?)

Hi,

 

Some comments:

 

Ø  One idea has been to extend the number of generic exception

 

I think deriving from a derived exception just adds complexity without real benefit. That is, it would be redundant since they differ only by the error message.  I don’t see an application doing a catch() for each exception type or doing dynamic cast for handling it. A better (and cheaper) alternative is to add a numeric FDO error code.

 

Ø  The GetNativeErrorCode thought is a good one, but by using it in an application, they would really have to know which provider returned that code

 

Usually a native error message contains some sort of RDBMS auto identification. The code that retrieves the native error can add a prefix in case it doesn’t.

 

Ø  and do some form of look-up to determine what it actually means.

 

The underlying code can figure out what it means because we know the specific RDBMS operation that just generated it (see the RDBI error codes). A more detailed explanation is provided by the native error code.

 

A different issue: I believe it would be useful to be able to distinguish between fatal errors and warnings. One little flag will do it. Alternatively, the numeric code for warnings should be (say) over 10000 and add a method IsAWarning() to hide the details.

 

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Greg Boone
Sent: Monday, June 01, 2009 5:29 PM
To: FDO Internals Mail List
Subject: [fdo-internals] Enhanced Exception Types in FDO

 

Hi All,

 

I am currently struggling with the topic of error handling and exceptions in FDO, FDO Providers and applications that use them. I would like to get some feedback from the community on how we could possibly resolve this issue in the next planned release of FDO (trunk).

 

Currently, the FDO API uses a throw/catch exception handling solution with the FdoException class being the root class for all exception types in the FDO architecture. The FDO API currently has  less than 10 derived exception classes to indicate the specific type of exception that has occurred in a provider, or application. The type of the exception object along with the exception message attached to the exception is the general extent of the error information that application developers can use to write provider/application specific error handling code. This lack of information makes it difficult for clients to get enough information concerning the error that occurred to take an appropriate action. Because of this limitation, applications are generally forced to catch only the base FdoException type, exit the routine gracefully, and show the error message to the user. 
 
Typically this mechanism really breaks down when dealing with database solutions such as Oracle, ODBC, MySQL, SQLite, etc.. where the underlying implementation provides a native error code to represent an error that has occurred. This native error code sometimes is accompanied by an error string or can be interpreted by the provider to generate an error message. However, for the client catching the error from the provider, interpreting the string is a difficult task. The client typically does not want to parse the string and generally has no knowledge of the native error that has occurred. 
 

So, how can we improve this mechanism and still allow developers to write generic applications against FDO that work with many types of providers?

 

One idea has been to extend the number of generic exception class types that FDO supports to support generic exceptions such as…

 

Constraint Exception:

 

    NullPropertyValue

    OutOfRangePropertyValue

    NotUniquePropertyvalue

    NotInListPropertyValue

 

Schema Exceptions:

 

    SchemaDoesNotExist

    SchemaAlreadyExists

    ClassDoesNotExist

    ClassAlreadyExists

    PropertyDoesNotExist

    PropertyAlreadyExists

 

Connection Exceptions:

 

    NotConnected

    WrongConnectionParameterValue

    InsufficientPrivaledges

 

Command Exceptions:

 

    SQLCommand

    InvalidSQLStatement

 

 

 

 

While this approach  would allow a certain level of flexibility in writing standardized FDO applications and its utilities, it still does not offer any real ability to access the underlying native error code in a generic manner, especially for RDBMS providers.

 

Here are some other quick ideas that I thought of:

 

1)      Add RDBMS specific exception types to the FDO API

2)      Add a GetNativeErrorCode method to FdoException that would return the error code returned by the underlying datastore/database

 

The first idea of adding RDBMS specific exception types may help a little, but may further complicate the try.. catch error handling strategy that applications are forced to implement. It also may limit the manner in which generic code can be written, and in the end still not be sufficient to meet all our clients requirements.

 

The GetNativeErrorCode thought is a good one, but by using it in an application, they would really have to know which provider returned that code and do some form of look-up to determine what it actually means. This would reduce the amount of generic provider agnostic code that applications can effectively write. I can see IsOracle() or IsPostGIS() calls creeping into applications and developers attempt to take advantage.

So, with these thoughts in mind, I would like to solicit feedback from the community to gather your thoughts and ideas on how this issue could be dealt with effectively. There has been a lot of provider development on Oracle/PostGIS/SQLite/MySQL/ODBC, etc, in the last number of years. What do you as provider developers think of the ideas expressed above? What error handling issues have you run up against that would have liked to have seen solved generically in the FDO API?  What ideas and thoughts do you have that may help me come to some conclusions on this topic and move forward?

 

Regards,

Greg



_______________________________________________
fdo-internals mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fdo-internals
Greg Boone

RE: Enhanced Exception Types in FDO

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)

[GB] See inline…

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Dan Stoica
Sent: Thursday, June 04, 2009 3:01 PM
To: FDO Internals Mail List
Subject: [fdo-internals] RE: Enhanced Exception Types in FDO

 

Hi,

 

Some comments:

 

Ø  One idea has been to extend the number of generic exception

 

I think deriving from a derived exception just adds complexity without real benefit. That is, it would be redundant since they differ only by the error message.  I don’t see an application doing a catch() for each exception type or doing dynamic cast for handling it. A better (and cheaper) alternative is to add a numeric FDO error code.

[GB] I don’t see it as being redundant. The fact that the exception classes are typed allows for greater flexibility when adding exception handling code. Applications would not catch every exception separately in all cases. Only if there is an expectation that one of the new exceptions will be thrown will the application insert the specific exception handling code, catch the error and take subsequent action. All other errors can be caught by a application level error handling mechanism.

 

However, I do agree that the extended exception types alone may not be sufficient for the application to take a secondary action. I guess I see these new types being used in conjunction with other extensions to the exception system in FDO to provide greater flexibility to the user.

 

Ø  The GetNativeErrorCode thought is a good one, but by using it in an application, they would really have to know which provider returned that code

 

Usually a native error message contains some sort of RDBMS auto identification. The code that retrieves the native error can add a prefix in case it doesn’t.

[GB] Even if a prefix is added, the client application would require some code to determine what the prefix is. For me, this is not that much different than having specialized code to determine what provider was being accessed when the exception was thrown.  6 of one half a dozen of another….

 

NOTE: I must point out here that while messy, the concept of native error code handling is an issue that  other "data format agnostic" APIs have to deal with and do so without great gnashing of teeth. This includes ADO.Net and JDBC. So, this idea is not without precedent. We simply may have to bite the proverbial bullet here and accept some form of native error code concept in the API if we wish greater adoption. Ultimately, it will be up to the clients themselves to determine if they wish to handle these codes, and in turn write less provider-agnostic implementations.

 

Ø  and do some form of look-up to determine what it actually means.

 

The underlying code can figure out what it means because we know the specific RDBMS operation that just generated it (see the RDBI error codes). A more detailed explanation is provided by the native error code.

 

A different issue: I believe it would be useful to be able to distinguish between fatal errors and warnings. One little flag will do it. Alternatively, the numeric code for warnings should be (say) over 10000 and add a method IsAWarning() to hide the details.

 

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Greg Boone
Sent: Monday, June 01, 2009 5:29 PM
To: FDO Internals Mail List
Subject: [fdo-internals] Enhanced Exception Types in FDO

 

Hi All,

 

I am currently struggling with the topic of error handling and exceptions in FDO, FDO Providers and applications that use them. I would like to get some feedback from the community on how we could possibly resolve this issue in the next planned release of FDO (trunk).

 

Currently, the FDO API uses a throw/catch exception handling solution with the FdoException class being the root class for all exception types in the FDO architecture. The FDO API currently has  less than 10 derived exception classes to indicate the specific type of exception that has occurred in a provider, or application. The type of the exception object along with the exception message attached to the exception is the general extent of the error information that application developers can use to write provider/application specific error handling code. This lack of information makes it difficult for clients to get enough information concerning the error that occurred to take an appropriate action. Because of this limitation, applications are generally forced to catch only the base FdoException type, exit the routine gracefully, and show the error message to the user. 
 
Typically this mechanism really breaks down when dealing with database solutions such as Oracle, ODBC, MySQL, SQLite, etc.. where the underlying implementation provides a native error code to represent an error that has occurred. This native error code sometimes is accompanied by an error string or can be interpreted by the provider to generate an error message. However, for the client catching the error from the provider, interpreting the string is a difficult task. The client typically does not want to parse the string and generally has no knowledge of the native error that has occurred. 
 

So, how can we improve this mechanism and still allow developers to write generic applications against FDO that work with many types of providers?

 

One idea has been to extend the number of generic exception class types that FDO supports to support generic exceptions such as…

 

Constraint Exception:

 

    NullPropertyValue

    OutOfRangePropertyValue

    NotUniquePropertyvalue

    NotInListPropertyValue

 

Schema Exceptions:

 

    SchemaDoesNotExist

    SchemaAlreadyExists

    ClassDoesNotExist

    ClassAlreadyExists

    PropertyDoesNotExist

    PropertyAlreadyExists

 

Connection Exceptions:

 

    NotConnected

    WrongConnectionParameterValue

    InsufficientPrivaledges

 

Command Exceptions:

 

    SQLCommand

    InvalidSQLStatement

 

 

 

 

While this approach  would allow a certain level of flexibility in writing standardized FDO applications and its utilities, it still does not offer any real ability to access the underlying native error code in a generic manner, especially for RDBMS providers.

 

Here are some other quick ideas that I thought of:

 

1)      Add RDBMS specific exception types to the FDO API

2)      Add a GetNativeErrorCode method to FdoException that would return the error code returned by the underlying datastore/database

 

The first idea of adding RDBMS specific exception types may help a little, but may further complicate the try.. catch error handling strategy that applications are forced to implement. It also may limit the manner in which generic code can be written, and in the end still not be sufficient to meet all our clients requirements.

 

The GetNativeErrorCode thought is a good one, but by using it in an application, they would really have to know which provider returned that code and do some form of look-up to determine what it actually means. This would reduce the amount of generic provider agnostic code that applications can effectively write. I can see IsOracle() or IsPostGIS() calls creeping into applications and developers attempt to take advantage.

So, with these thoughts in mind, I would like to solicit feedback from the community to gather your thoughts and ideas on how this issue could be dealt with effectively. There has been a lot of provider development on Oracle/PostGIS/SQLite/MySQL/ODBC, etc, in the last number of years. What do you as provider developers think of the ideas expressed above? What error handling issues have you run up against that would have liked to have seen solved generically in the FDO API?  What ideas and thoughts do you have that may help me come to some conclusions on this topic and move forward?

 

Regards,

Greg



_______________________________________________
fdo-internals mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fdo-internals
Dan Stoica

RE: Enhanced Exception Types in FDO

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)

Let’s have a look at JDBC and error handling:

http://www.docjar.com/docs/api/java/sql/SQLException.html

 

Basically there are a bunch of derived classes (of little interest of us), but the most important are SQLWarningException and DataTruncationException.

 

I think this SQLException class is pretty powerful and flexible. Note the error messages can be chained. Here are its members:

1.   A string describing the error. This is used as the Java Exception message, available via the getMessage method.

2.   A "SQLState" string, which follows the XOPEN SQLState conventions.

3.   An integer error code that is specific to each vendor.

We could easily do something similar by extending FdoIException API. A chain of messages limited to 2 items is equivalent to GetNativeErrorCode() approach.

 

 (as opposed to creating  N subclasses and keep adding new ones in the future).

 

Hope this clarifies my position.

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Greg Boone
Sent: Thursday, June 04, 2009 3:23 PM
To: FDO Internals Mail List
Subject: [fdo-internals] RE: Enhanced Exception Types in FDO

 

[GB] See inline…

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Dan Stoica
Sent: Thursday, June 04, 2009 3:01 PM
To: FDO Internals Mail List
Subject: [fdo-internals] RE: Enhanced Exception Types in FDO

 

Hi,

 

Some comments:

 

Ø  One idea has been to extend the number of generic exception

 

I think deriving from a derived exception just adds complexity without real benefit. That is, it would be redundant since they differ only by the error message.  I don’t see an application doing a catch() for each exception type or doing dynamic cast for handling it. A better (and cheaper) alternative is to add a numeric FDO error code.

[GB] I don’t see it as being redundant. The fact that the exception classes are typed allows for greater flexibility when adding exception handling code. Applications would not catch every exception separately in all cases. Only if there is an expectation that one of the new exceptions will be thrown will the application insert the specific exception handling code, catch the error and take subsequent action. All other errors can be caught by a application level error handling mechanism.

 

However, I do agree that the extended exception types alone may not be sufficient for the application to take a secondary action. I guess I see these new types being used in conjunction with other extensions to the exception system in FDO to provide greater flexibility to the user.

 

Ø  The GetNativeErrorCode thought is a good one, but by using it in an application, they would really have to know which provider returned that code

 

Usually a native error message contains some sort of RDBMS auto identification. The code that retrieves the native error can add a prefix in case it doesn’t.

[GB] Even if a prefix is added, the client application would require some code to determine what the prefix is. For me, this is not that much different than having specialized code to determine what provider was being accessed when the exception was thrown.  6 of one half a dozen of another….

 

NOTE: I must point out here that while messy, the concept of native error code handling is an issue that  other "data format agnostic" APIs have to deal with and do so without great gnashing of teeth. This includes ADO.Net and JDBC. So, this idea is not without precedent. We simply may have to bite the proverbial bullet here and accept some form of native error code concept in the API if we wish greater adoption. Ultimately, it will be up to the clients themselves to determine if they wish to handle these codes, and in turn write less provider-agnostic implementations.

 

Ø  and do some form of look-up to determine what it actually means.

 

The underlying code can figure out what it means because we know the specific RDBMS operation that just generated it (see the RDBI error codes). A more detailed explanation is provided by the native error code.

 

A different issue: I believe it would be useful to be able to distinguish between fatal errors and warnings. One little flag will do it. Alternatively, the numeric code for warnings should be (say) over 10000 and add a method IsAWarning() to hide the details.

 

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Greg Boone
Sent: Monday, June 01, 2009 5:29 PM
To: FDO Internals Mail List
Subject: [fdo-internals] Enhanced Exception Types in FDO

 

Hi All,

 

I am currently struggling with the topic of error handling and exceptions in FDO, FDO Providers and applications that use them. I would like to get some feedback from the community on how we could possibly resolve this issue in the next planned release of FDO (trunk).

 

Currently, the FDO API uses a throw/catch exception handling solution with the FdoException class being the root class for all exception types in the FDO architecture. The FDO API currently has  less than 10 derived exception classes to indicate the specific type of exception that has occurred in a provider, or application. The type of the exception object along with the exception message attached to the exception is the general extent of the error information that application developers can use to write provider/application specific error handling code. This lack of information makes it difficult for clients to get enough information concerning the error that occurred to take an appropriate action. Because of this limitation, applications are generally forced to catch only the base FdoException type, exit the routine gracefully, and show the error message to the user. 
 
Typically this mechanism really breaks down when dealing with database solutions such as Oracle, ODBC, MySQL, SQLite, etc.. where the underlying implementation provides a native error code to represent an error that has occurred. This native error code sometimes is accompanied by an error string or can be interpreted by the provider to generate an error message. However, for the client catching the error from the provider, interpreting the string is a difficult task. The client typically does not want to parse the string and generally has no knowledge of the native error that has occurred. 
 

So, how can we improve this mechanism and still allow developers to write generic applications against FDO that work with many types of providers?

 

One idea has been to extend the number of generic exception class types that FDO supports to support generic exceptions such as…

 

Constraint Exception:

 

    NullPropertyValue

    OutOfRangePropertyValue

    NotUniquePropertyvalue

    NotInListPropertyValue

 

Schema Exceptions:

 

    SchemaDoesNotExist

    SchemaAlreadyExists

    ClassDoesNotExist

    ClassAlreadyExists

    PropertyDoesNotExist

    PropertyAlreadyExists

 

Connection Exceptions:

 

    NotConnected

    WrongConnectionParameterValue

    InsufficientPrivaledges

 

Command Exceptions:

 

    SQLCommand

    InvalidSQLStatement

 

 

 

 

While this approach  would allow a certain level of flexibility in writing standardized FDO applications and its utilities, it still does not offer any real ability to access the underlying native error code in a generic manner, especially for RDBMS providers.

 

Here are some other quick ideas that I thought of:

 

1)      Add RDBMS specific exception types to the FDO API

2)      Add a GetNativeErrorCode method to FdoException that would return the error code returned by the underlying datastore/database

 

The first idea of adding RDBMS specific exception types may help a little, but may further complicate the try.. catch error handling strategy that applications are forced to implement. It also may limit the manner in which generic code can be written, and in the end still not be sufficient to meet all our clients requirements.

 

The GetNativeErrorCode thought is a good one, but by using it in an application, they would really have to know which provider returned that code and do some form of look-up to determine what it actually means. This would reduce the amount of generic provider agnostic code that applications can effectively write. I can see IsOracle() or IsPostGIS() calls creeping into applications and developers attempt to take advantage.

So, with these thoughts in mind, I would like to solicit feedback from the community to gather your thoughts and ideas on how this issue could be dealt with effectively. There has been a lot of provider development on Oracle/PostGIS/SQLite/MySQL/ODBC, etc, in the last number of years. What do you as provider developers think of the ideas expressed above? What error handling issues have you run up against that would have liked to have seen solved generically in the FDO API?  What ideas and thoughts do you have that may help me come to some conclusions on this topic and move forward?

 

Regards,

Greg



_______________________________________________
fdo-internals mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fdo-internals