Key-Value Store
Custom Entity Store
SQL (Preview)
Cache (EAP)

Error handling for Forge SQL

The Preview version of Forge SQL currently does not support data residency. By using Forge SQL, you acknowledge that Section 6 (Data Residency) of the Forge Terms does not apply to data stored using Forge SQL, and you must not use Forge SQL for any applications that require data residency. For more details, please see the Data residency limitations section.

The @forge/sql package exports error codes. The following example shows how the package handles a QUERY_TIMED_OUT error:

1
2
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_OUTThe 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_ERRORThe provided query was either incorrect or could not be executed at the database level.
More details are present in the  debug field.
INVALID_SQL_QUERYThe provided query is not compliant with ANSI SQL.

Rate this page: