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
| Property | Type | Description |
|---|---|---|
message | string | The error message (from the wrapped adapter error). |
cause | Error | undefined | The original error thrown by the adapter. |
query | string | Query | The query (raw SQL or Query builder object) that was being executed. |
queryOptions | QueryExecuteOptions | undefined | The options passed to execute(). |
request | QueryRequest | undefined | The 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);
}
}