The @forge/sql
package exports error codes. The following example shows how the package handles a
QUERY_TIMED_OUT
error:
1 2 3 4 5 6 7 8 9 10 11 12 13
import sql, { errorCodes } from '@forge/sql'; try { await sql .prepare("INSERT INTO city (id, city, population) VALUES (?, ?, ?)") .bindParams(1, "Beijing", 100) .execute(); } catch (error) { if (error.code === errorCodes.QUERY_TIMED_OUT) { // Handle query timeout } }
Error code | Description |
---|---|
QUERY_TIMED_OUT | The provided query took more than 2 seconds to execute. During EAP, executing queries that run for more than 10 seconds will trigger a QUERY_TIMED_OUT error. This occurs because the HTTP connection is being terminated, but the query continue executing at the database level. |
SQL_EXECUTION_ERROR | The provided query was either incorrect or could not be executed at the database level. More details are present in the debug field. |
INVALID_SQL_QUERY | The provided query is not compliant with ANSI SQL. |
Rate this page: