Skip to main content

SQBError

SQBError is the error class @sqb/connect wraps every query-execution failure in. It's thrown from SqbConnection.execute() (and, transitively, from SqbClient.execute()) whenever the underlying adapter call throws.

note

The exported symbol is SQBError (all caps "SQB"), not SqbError.

SQBError extends Error.

Constructor

new SQBError(message: string, cause?: Error)

You don't normally construct an SQBError yourself — SqbConnection wraps adapter errors in one internally, copying the original error's stack when a cause is given.

Properties

PropertyTypeDescription
messagestringThe error message (from the wrapped adapter error).
causeError | undefinedThe original error thrown by the adapter.
querystring | QueryThe query (raw SQL or Query builder object) that was being executed.
queryOptionsQueryExecuteOptions | undefinedThe options passed to execute().
requestQueryRequest | undefinedThe fully-resolved request (SQL, params, and effective options) that was sent to the adapter.
try {
await client.execute('select * from no_such_table');
} catch (e) {
if (e instanceof SQBError) {
console.error(e.message, e.request?.sql, e.cause);
}
}