GOLF(2gg)

NAME
db-error - (database error-handling)

PURPOSE
Either exit request or continue processing when there is an error in a database statement.

SYNTAX

        db-error [ @<database> ] ( exit | continue )

DESCRIPTION
db-error sets the response to the failure of database statements. You can change this response at run-time with each execution of db-error.

When a database statement (like run-query) fails, Golf will either exit request processing if "exit" is used, or continue if "continue" is used. "Exiting" is equivalent to calling report-error with the message containing details about the error. "Continuing" means that your program will continue but you should examine error code (see for instance "error" clause in run-query).

The default action is "exit". You can switch back and forth between "exit" and "continue". Typically, "exit" is preferable because errors in database statemets generally mean application or setup issues, however "continue" may be used when application wants to attempt to recover from errors or perform other actions.

Note that you can override the effect of db-error for a specific database statement by using clauses like "on-error-continue" and "on-error-exit" in run-query.

DATABASE

<database> is specified in "@" clause and is the name of the database-config-file. If omitted, your program must use exactly one database (see --db option in gg).

EXAMPLES
The following will not exit when errors happen going forward, but rather continue execution (and you should check every error henceforth):

        db-error @mydb continue

SEE ALSO
 Database

begin-transaction commit-transaction current-row database-config-file db-error mariadb-database postgresql-database rollback-transaction run-query sqlite-database
 Error handling

db-error error-code error-handling report-error See all documentation