361 users using DBSP now!
home -> documentation -> environment guide -> Handling database exceptions



All the relational databases supported by DBSP have their own methods to follow predefined rules and enforce the integrity of the database. Some of these rules are established as integrity constraints in the metadata of the database (DDL). Others are raised inside stored procedures, triggers, etc.

Regarding what kind of exceptions the database are raising, is a need to present to the user a clear explanation of what is happening inside the system and why he or she is violating these rules. This could be done using the TRY-ONERROR tags.

Try - OnError Tags

These tags works like any of the try-catch blocks found on all the recent high level programming languages. The structure is very simple:

<#TRY>

-- any exception raised here --

<#ONERROR/>

-- is handled here --

<#/TRY>

When an exception is raised inside the TRY-ONERROR block, the block delimited by the ONERROR - /TRY is executed. This block could be used for handling the exception and present an explanation to the user or redirect to another page that contains all these explanations.

Note: If an exception is raised and is not explicitly handled within a TRY-ONERROR block, then DBSP takes one of the following actions:

If the DEBUGMODE parameter in the file DBSP.ini is turned on (TRUE), a template file containing detailed explanation is displayed. This template (debugerror.dbsp) is located in the bin\Templates directory inside the installation directory.

If the DEBUGMODE parameter is turned off (FALSE), the production error template (productionerror.dbsp) is displayed instead.

Examples

Example 1. Managing check constraints exceptions

This example shows you how trap exceptions raised by the RDBMS.

Source code