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

Error handling for Forge SQL

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: