Postgres error codes

Need to step up my error handling in my app that connects to a Postgresql db. One thing I want to do is be able to handle connectivity errors differently from SQL select errors. Unfortunately Xojo is returning error codes that are the same for multiple classes of errors, generally code “3”. Is there a reason that the XOJO driver is not returning the native error codes?

Not much more than because the database API never has returned native codes and has mapped them into Database API error codes
Might be useful to have a means to have that API error code & the underlying db plugin native error code
Not sure if there’s an FR for such a thing

Depends on the amount of work…For me I’d like to have the native codes, but there are a lot, and it might be overwhelming for some applications to deal with all the codes.

With the base Database API what doe the codes correspond to? For example PGRES will throw a range of connectivity errors, from lost connection to server terminated but the error code returned will be either one or three. I also get the code there for SQL statements that reference missing resources. Obviously it would be nice to handle the concavity class of errors differently than the SQL errors.

Is that something that would work well with the XOJO codes?

you could switch to MBS SQL plugin and get native error codes.

and by concavity I meant connectivity…

Christian - You do great work. Id’ have to look into moving my DB support off of the native classes. Also there would have to be some other significant benefits as well. I have so many third party libraries, DLL’s and plugins that any opportunity to stay with the native libraries is refreshing.

Well, if you use SQLDatabaseMBS class, you have not much to change in code.

I’d almost expect that the DB Api could be made to have two properties on the db instance

  1. the mapped db api error code
  2. the raw underlying native error code

That would probably let anyone do what they wanted without much work.
Existing code would continue working and no changes would be required unless you wanted these extra codes.