feat(node): surface Rust errors as typed JavaScript errors (#4901)

## Summary
The Node SDK now throws typed `LanceError` subclasses instead of one
generic `Error` with an indented `Caused by` string.

Fixes #222

## Before / after
```ts
try {
  await db.openTable(\"missing\");
} catch (error) {
  if (error instanceof TableNotFoundError) {
    error.code;       // \"TableNotFound\"
    error.tableName;  // \"missing\"
    error.message;    // \"Table 'missing' was not found\"
    error.cause;      // underlying dataset error
  }
}
```

## Changes
- `nodejs/src/error.rs` — map each `lancedb::Error` variant to a
one-line header + `error.cause`
- `nodejs/src/query.rs`, `nodejs/src/merge.rs` — pass errors through
instead of stringifying
- `nodejs/lancedb/errors.ts`, `errors_install.ts` — real subclasses when
the package loads
- Tests + generated API docs under `docs/src/js/`

## Test plan
- [x] Native debug build, `tsc`, Biome, `cargo clippy -p lancedb-nodejs`
- [x] Jest: new error tests, remote retry, connection/query/table (594
passed)

## Notes
Node-API cannot construct a custom `Error` subclass from an async Rust
rejection, so translation happens in JS when `@lancedb/lancedb` loads.
Calling the raw native addon without that entrypoint still shows the
header line.

---------

Signed-off-by: ZYZ666-RGB <1991039819@qq.com>
Signed-off-by: yuzhou <1991039819@qq.com>
Co-authored-by: Xuanwo <github@xuanwo.io>
This commit is contained in:
yuzhou
2026-12-01 11:28:22 +08:00
committed by GitHub
co-authored by Xuanwo
parent 071c220713
commit b3ad97a28d
49 changed files with 16626 additions and 96 deletions
+466
View File
@@ -0,0 +1,466 @@
[**@lancedb/lancedb**](../README.md) • **Docs**
***
[@lancedb/lancedb](../globals.md) / InvalidInputError
# Class: InvalidInputError
Input rejected before it reached storage.
## Extends
- [`LanceError`](LanceError.md)
## Extended by
- [`InvalidExpressionError`](InvalidExpressionError.md)
- [`InvalidTableNameError`](InvalidTableNameError.md)
- [`NotAMaterializedViewError`](NotAMaterializedViewError.md)
- [`SchemaError`](SchemaError.md)
## Constructors
### new InvalidInputError()
```ts
new InvalidInputError(message, options?): InvalidInputError
```
#### Parameters
* **message**: `string`
* **options?**: [`LanceErrorOptions`](../interfaces/LanceErrorOptions.md)
#### Returns
[`InvalidInputError`](InvalidInputError.md)
#### Inherited from
[`LanceError`](LanceError.md).[`constructor`](LanceError.md#constructors)
## Properties
### cause?
```ts
optional cause: unknown;
```
#### Inherited from
[`LanceError`](LanceError.md).[`cause`](LanceError.md#cause)
***
### code
```ts
readonly code: string;
```
#### Inherited from
[`LanceError`](LanceError.md).[`code`](LanceError.md#code)
***
### columnName?
```ts
readonly optional columnName: string;
```
#### Inherited from
[`LanceError`](LanceError.md).[`columnName`](LanceError.md#columnname)
***
### connectFailures?
```ts
readonly optional connectFailures: number;
```
#### Inherited from
[`LanceError`](LanceError.md).[`connectFailures`](LanceError.md#connectfailures)
***
### databaseName?
```ts
readonly optional databaseName: string;
```
#### Inherited from
[`LanceError`](LanceError.md).[`databaseName`](LanceError.md#databasename)
***
### errorCode?
```ts
readonly optional errorCode: string;
```
#### Inherited from
[`LanceError`](LanceError.md).[`errorCode`](LanceError.md#errorcode)
***
### functionName?
```ts
readonly optional functionName: string;
```
#### Inherited from
[`LanceError`](LanceError.md).[`functionName`](LanceError.md#functionname)
***
### grpcCode?
```ts
readonly optional grpcCode: number;
```
#### Inherited from
[`LanceError`](LanceError.md).[`grpcCode`](LanceError.md#grpccode)
***
### indexName?
```ts
readonly optional indexName: string;
```
#### Inherited from
[`LanceError`](LanceError.md).[`indexName`](LanceError.md#indexname)
***
### jobId?
```ts
readonly optional jobId: string;
```
#### Inherited from
[`LanceError`](LanceError.md).[`jobId`](LanceError.md#jobid)
***
### jobRequestId?
```ts
readonly optional jobRequestId: string;
```
#### Inherited from
[`LanceError`](LanceError.md).[`jobRequestId`](LanceError.md#jobrequestid)
***
### maxConnectFailures?
```ts
readonly optional maxConnectFailures: number;
```
#### Inherited from
[`LanceError`](LanceError.md).[`maxConnectFailures`](LanceError.md#maxconnectfailures)
***
### maxReadFailures?
```ts
readonly optional maxReadFailures: number;
```
#### Inherited from
[`LanceError`](LanceError.md).[`maxReadFailures`](LanceError.md#maxreadfailures)
***
### maxRequestFailures?
```ts
readonly optional maxRequestFailures: number;
```
#### Inherited from
[`LanceError`](LanceError.md).[`maxRequestFailures`](LanceError.md#maxrequestfailures)
***
### message
```ts
message: string;
```
#### Inherited from
[`LanceError`](LanceError.md).[`message`](LanceError.md#message)
***
### name
```ts
name: string;
```
#### Inherited from
[`LanceError`](LanceError.md).[`name`](LanceError.md#name)
***
### namespacePath?
```ts
readonly optional namespacePath: string[];
```
#### Inherited from
[`LanceError`](LanceError.md).[`namespacePath`](LanceError.md#namespacepath)
***
### path?
```ts
readonly optional path: string;
```
#### Inherited from
[`LanceError`](LanceError.md).[`path`](LanceError.md#path)
***
### phase?
```ts
readonly optional phase: string;
```
#### Inherited from
[`LanceError`](LanceError.md).[`phase`](LanceError.md#phase)
***
### readFailures?
```ts
readonly optional readFailures: number;
```
#### Inherited from
[`LanceError`](LanceError.md).[`readFailures`](LanceError.md#readfailures)
***
### requestFailures?
```ts
readonly optional requestFailures: number;
```
#### Inherited from
[`LanceError`](LanceError.md).[`requestFailures`](LanceError.md#requestfailures)
***
### requestId?
```ts
readonly optional requestId: string;
```
#### Inherited from
[`LanceError`](LanceError.md).[`requestId`](LanceError.md#requestid)
***
### resourceKind?
```ts
readonly optional resourceKind: string;
```
#### Inherited from
[`LanceError`](LanceError.md).[`resourceKind`](LanceError.md#resourcekind)
***
### resourceName?
```ts
readonly optional resourceName: string;
```
#### Inherited from
[`LanceError`](LanceError.md).[`resourceName`](LanceError.md#resourcename)
***
### retryable?
```ts
readonly optional retryable: boolean;
```
#### Inherited from
[`LanceError`](LanceError.md).[`retryable`](LanceError.md#retryable)
***
### sqlJobId?
```ts
readonly optional sqlJobId: string;
```
#### Inherited from
[`LanceError`](LanceError.md).[`sqlJobId`](LanceError.md#sqljobid)
***
### stack?
```ts
optional stack: string;
```
#### Inherited from
[`LanceError`](LanceError.md).[`stack`](LanceError.md#stack)
***
### statusCode?
```ts
readonly optional statusCode: number;
```
#### Inherited from
[`LanceError`](LanceError.md).[`statusCode`](LanceError.md#statuscode)
***
### tableName?
```ts
readonly optional tableName: string;
```
#### Inherited from
[`LanceError`](LanceError.md).[`tableName`](LanceError.md#tablename)
***
### code
```ts
readonly static code: string = "InvalidInput";
```
#### Overrides
[`LanceError`](LanceError.md).[`code`](LanceError.md#code-1)
***
### prepareStackTrace()?
```ts
static optional prepareStackTrace: (err, stackTraces) => any;
```
Optional override for formatting stack traces
#### Parameters
* **err**: `Error`
* **stackTraces**: `CallSite`[]
#### Returns
`any`
#### See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
#### Inherited from
[`LanceError`](LanceError.md).[`prepareStackTrace`](LanceError.md#preparestacktrace)
***
### stackTraceLimit
```ts
static stackTraceLimit: number;
```
#### Inherited from
[`LanceError`](LanceError.md).[`stackTraceLimit`](LanceError.md#stacktracelimit)
## Methods
### captureStackTrace()
```ts
static captureStackTrace(targetObject, constructorOpt?): void
```
Create .stack property on a target object
#### Parameters
* **targetObject**: `object`
* **constructorOpt?**: `Function`
#### Returns
`void`
#### Inherited from
[`LanceError`](LanceError.md).[`captureStackTrace`](LanceError.md#capturestacktrace)