How SQL Yoga Reports Errors
Before we continue on to the various SQL Yoga objects and how to use them we are going to mention a few things about how SQL Yoga reports errors. Knowing how to properly track down errors will save you a lot of time and headaches.
Connection and SQL Query Errors
SQL Yoga will throw an error if something goes wrong when connecting to the database or when executing a SQL query.
If an error occurs while trying to connect to the database then an error prefixed with sqlyoga_connection_err, will be thrown. Having the error thrown allows your application to handle lost database connections globally. For example, you can add an errorDialog handler to the message path that alerts the user if a connection to the database cannot be made or disappears during a session.
on errorDialog pError
if pError begins with "sqlyoga_connection_err" then
answer "The database connection has gone away. Try reconnecting later.
If an error occurs while trying to execute a SQL query then an error prefixed with sqlyoga_executesql_err, will be thrown. Invalid queries represent a programming mistake that needs to be addressed.
SQL Yoga will throw errors if you do one of the following:
1) Pass in an invalid object reference. For example, passing in the name of a table that does not exist to sqlquery_createObject.
2) Try to set an object property to an invalid value.
3) Try to set a non-existent property of a SQL Yoga object.
Other types of errors are returned in the result. For example, if you try to disconnect from a Database object and RevDB encounters an error then the result would contain the error message.
put the result into theError
theError now contains an error message if an error occurred.