-
Notifications
You must be signed in to change notification settings - Fork 4
Error Handling
Error reporting in SQL Yoga is of two types:
- Handlers that throw errors
- Handlers that return errors in
the result
SQL Yoga will handlers will throw errors if the error is a development error or if it is a database connection error. A development error means that the error is caused because you have misconfigured something or are trying to use the API incorrectly.
Here is a list of error numbers that are thrown and the | used in SQL Yoga which describes the erorr. The error number is the number used by LiveCode to report specific errors.
| Error Number | Description |
|---|---|
| 422 | kErrInvalidArray |
| 452 | kErrInvalidBoolean |
| 453 | kErrInvalidNumber |
| 456 | kErrPropDoesntExist |
| 354 | kErrInvalidInteger |
| 355 | kErrInvalidPoint |
| 356 | kErrInvalidRect |
| 449 | kErrReadOnlyProp |
| 348 | kErrInvalidProperty |
| 619 | kErrCantFindObject |
| 487 | kErrRenameErrorInDestination |
| 132 | kErrObjectNameTaken |
| 238 | kErrInvalidGroupObject |
| 219 | kErrErrorInFunction |
In addition to the general LiveCode errors above, SQL Yoga will also throw errors specific to SQL Yoga. Errors have one of the following prefixes, followed by a ,, followed by the specific error message.
| Error Prefix | Description |
|---|---|
| sqlyoga_connection_err | An error occurred while trying to connect to the database. |
| sqlyoga_executesql_err | An error occurred while trying to execute a SQL statement. |
There are two ways to handle errors that are thrown. The first is to wrap all calls to handlers that execute SQL statements or connect to the database with a try/catch statement:
try
dbconn_connect
catch e
answer "An error occurred while connecting to the database:" && e
end try
Another approach is to define your own errorDialog handler somewhere in the message path (e.g. a library script). When your app is running in the IDE you can pass the errorDialog message and allow the IDE to report the error to you using the standard error reporter.
When your app is running as a standalone you can define how you want to respond to errors at a global level. For example, if the database connection is invalid and a sqlyoga_connection_err error is thrown then you might want to display a dialog that allows them to update the connection settings.
# Card script
on openCard
# No try/catch arround handler that can throw an error
...
dbconn_connect
...
end openCard
# library script
on errorDialog pError
# Let the IDE display the error in development
if the environment is "development" then pass errorDialog
switch item 1 of pError
case "sqlyoga_connection_err"
# handle connection error here
break
end switch
end errorDialog
SQL Yoga USER GUIDE
- Home
- SQL Yoga Objects
- Database Objects
- Connection Objects
- SQL Query Objects
- SQL Record Objects
- Table Objects
- Table Object Behaviors
- Relationships
- Scopes
- Schema
- Working with User Search Strings
- SQL Query Template Objects
- Error Handling
- Migrating from SQL Yoga 1.x
- Integrating with the Levure Application Framework